olegkrivtsov / using-zend-framework-3-book Goto Github PK
View Code? Open in Web Editor NEWA free and reader-friendly book on Zend Framework 3
Home Page: https://olegkrivtsov.github.io/using-zend-framework-3-book/html
License: Other
A free and reader-friendly book on Zend Framework 3
Home Page: https://olegkrivtsov.github.io/using-zend-framework-3-book/html
License: Other
In section 17.2.1 of your ebook, you suggest creating roles 'Administrator,' 'Editor,' and 'Viewer.' 'Administrator' inherits permissions from 'Editor' and 'Editor' inherits permissions from 'Viewer.'
Using your code from section 17.2.2, where you add the roles along with their parents and establish a 'post.view' permission to the 'Viewer' role, I then tested to see if a user with the 'Administrator' role would correctly inherit the 'post.view' permission.
// Create Rbac container.
$rbac = new Rbac();
// The following is to tell Rbac to create some parent roles if not exist yet
$rbac->setCreateMissingRoles(true);
// Create role hierarchy
$rbac->addRole('Viewer', ['Editor', 'Author']);
$rbac->addRole('Editor', ['Administrator']);
$rbac->addRole('Author');
$rbac->addRole('Administrator');
// Assign permissions to the Viewer role.
$rbac->getRole('Viewer')->addPermission('post.view');
$rbac->isGranted('Administrator', 'post.view'); // returns false!!
The Rbac returns false when it should return true.
In 3 translations (EN line 357, RU line 343, FR line 333), this hyperlink could be redirect to another zend coding standard page to be more explicit.
The best way to do this might be to put the php-fig psr link used in the ES translation.
Which one may I choose?
Whatever application uses logging and very often caching or other services (doctrine?). How to pass this services to every controller and not add thousands parameters to the constructors? Similar way like default session manager in chapter 15.3.2.
Hi Oleg,
There are three excellent ZF3 resources - yours and two others. I thought maybe there'd be a good place to mention them somewhere?
I have no affiliation - just a dev.
They are:
Alexander Romanenko
https://www.youtube.com/user/integral30/playlists
And Matthew Setter
http://www.masterzendframework.com/
Hi,
I would be very appreciate, if you extend a bit chapter 7 (7.13.1). I tried to create quite complicated form with group of radios and checkboxes and it makes me a troubles. Label are rendered the same way (I mean label for whole group and label for every single radio / checkbox). The second is "decorators" - I need to wrap every radio with div.radio, but I failed. Whatever advice I found uses decorators, but in zend source is not used any of this. And to write my own element for such a basic task I suppose a bad idea.
Thank you very much
Vladimir Naprstek
Hi,
what about dependant form elements? It means one field is required, when value on other field is set. For example, field paymentMethod (radios) contains values: credit card, bank transfer and cash. In first case, field cardNumber is required, second makes bankAccount required and third has no depending field.
Pass form data to form constructor and define validation rules based on that data looks ugly...
Hi!
I would love to feature this book on DevZone.zend.com. However, even thought you say it is a free and open source book, there is no license attached to the project. My personal favorite is the MIT license, but there are a lot of them to choose from.
Please attach a license so the rest of us know what we can do with the book. :)
Cheers!
=C=
Is there any idea around to migrate the book to Laminas? Or are you aware of others who did it?
Information about working with Events (ListenerAggregates and etc) should be separated in different chapter from chapter about Modules.
I think so because there is a lot more things to describe and explain, not only usage in context of Module.
$ composer require doctrine/doctrine-orm-module
Using version ^2.1 for doctrine/doctrine-orm-module
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages
Problem 1
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.7
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.6
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.5
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.4
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.3
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.2
- Conclusion: don't install doctrine/doctrine-orm-module 2.1.1
- Conclusion: remove zendframework/zend-hydrator 3.0.2
- Installation request for doctrine/doctrine-orm-module ^2.1 -> satis
.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.1.7].
- Conclusion: don't install zendframework/zend-hydrator 3.0.2
- doctrine/doctrine-orm-module 2.1.0 requires zendframework/zend-hydr
nd-hydrator[1.1.0, 2.2.1, 2.2.2, 2.2.3, 2.3.0, 2.3.1, 2.4.0, 2.4.1, 2.4.2
- Can only install one of: zendframework/zend-hydrator[1.1.0, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.2.1, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.2.2, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.2.3, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.3.0, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.3.1, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.4.0, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.4.1, 3.0.2].
- Can only install one of: zendframework/zend-hydrator[2.4.2, 3.0.2].
- Installation request for zendframework/zend-hydrator (locked at 3.0.2]
Installation failed, reverting ./composer.json to its original content.
Hi Oleg,
In roledemo/module/User/src/Module.php
, you're grabbing the sharedEventManager
. Are you sure this is necessary? Because you're doing getApplication()->getEventManager()
, I think you'd be getting the Application's own instance of the event manager (not a new one). Thus, no need to use the shared functionality.
Other auth examples I've seen just attach to the 'usual' Event Manager.
Need to print it as paperback version using printer, but where is PDF?
I used http://www.httrack.com/
but i cant make it as a PDF, can you please give some way to have it also as PDF instead of all individual HTml pages?
look for source code:
return [
// ...
// The following registers our custom view
// helper classes in view plugin manager.
'view_helpers' => [
'factories' => [
View\Helper\Menu::class => InvokableFactory::class,
],
'aliases' = [
'mainMenu' => View\Helper\Menu::class
]
],
];
setting of array key "aliases":
Hello Oleg,
Thanks for the work. I'm new to ZF3. It helped a lot to understand a lot.
Could you please help me how I could insert a join query from a second table?
I tried it in User \ Entity, but unfortunately without success.
Or do I have to create a second entity file with separate DB Table and then the query in get ..... install.
in zend1 i just took select statements.
thanks
best regards from germany
Installing doctrine cause conflicts with current skeleton app, so i install next versions:
Rus Lang:
чтобы доктрина встала при установке композером, нужно установить версию скелетного приложения 3.0.3 c минимальным количеством пакетов
затем установить doctrine-module:1.2.0
composer require doctrine/doctrine-module:1.2.0
затем версию доктрины 1.1.8
composer require doctrine/doctrine-orm-module:1.1.8
Остальные варианты вызывают конфликты пакетов. У меня только так установилось.
I found somewhere abstract controller factory which use reflection to instantiate controllers. It may simplify an application.
use Interop\Container\ContainerInterface;
use ReflectionClass;
use Zend\ServiceManager\Factory\AbstractFactoryInterface;
class AbstractControllerFactory implements AbstractFactoryInterface
{
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
// Construct a new ReflectionClass object for the requested action
$reflection = new ReflectionClass($requestedName);
// Get the constructor
$constructor = $reflection->getConstructor();
if (is_null($constructor)) {
// There is no constructor, just return a new class
return new $requestedName;
}
// Get the parameters
$parameters = $constructor->getParameters();
$dependencies = [];
foreach ($parameters as $parameter) {
// Get the parameter class
$class = $parameter->getClass();
// Get the class from the container
$dependencies[] = $container->get($class->getName());
}
// Return the requested class and inject its dependencies
return $reflection->newInstanceArgs($dependencies);
}
public function canCreate(ContainerInterface $container, $requestedName)
{
// Only accept Controller classes
list( $module, ) = explode('\\', __NAMESPACE__, 2);
return strstr($requestedName, $module . '\Controller') !== false;
}
}
and then in module.config.php just list abstract factory:
'controllers' => [
'abstract_factories' => [
AbstractControllerFactory::class,
]
],
The file encoding was set to UTF-8 (with BOM) instead of UTF-8 (without BOM).
Few posts about creating and admin panel ( eg. displaying all users that should be visible just for admins ) + admin layout implementation would be helpful to have in this brilliant tutorial too. What you think ?
Thank you
Is it possible to post an example/chapter in your book on how to create console scripts? Using the ServiceManager as well as the EntityManager in this examples would be great...
Followed your tutorial and got this error when I tried to go to the upload page. The file was originally upload.html but that produced another error that was fixed when I changed it to .phtml.
Please help
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.