Coder Social home page Coder Social logo

olegkrivtsov / using-zend-framework-3-book Goto Github PK

View Code? Open in Web Editor NEW
161.0 161.0 62.0 41.02 MB

A free and reader-friendly book on Zend Framework 3

Home Page: https://olegkrivtsov.github.io/using-zend-framework-3-book/html

License: Other

HTML 95.08% JavaScript 4.92%
beginner-friendly book free zend-framework

using-zend-framework-3-book's People

Contributors

arthurneves avatar asponch avatar bitwombat avatar celtic34fr avatar darwinc avatar davidmintz avatar giftnuss avatar igorconde avatar neira13 avatar olegkrivtsov avatar rodion-arr avatar samjudge avatar sidewaysgravity avatar spenwall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

using-zend-framework-3-book's Issues

Rbac Not Handling Ancestors Beyond Immediate Parent

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.

Advanced controller configuration

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.

Forms - decorators

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

Forms - advanced validation

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...

License?

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=

Migrate Book to Laminas?

Is there any idea around to migrate the book to Laminas? Or are you aware of others who did it?

[Proposal] Separate chapter about Events

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.

Не работает пример с установкой Doctrine 2 через composer на SkeletonApplication. Проблема с гидратором.

$ 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.

Shared event manager - reason?

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.

Typo at Page Page_Appearance_and_Layout/Writing_Own_View_Helpers (chapter 6.9)

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":

  • replace "=" with "=>"

Query 2 tables with join or separate select statement

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

Book need updates for instructions

Installing doctrine cause conflicts with current skeleton app, so i install next versions:

  1. Install ZFSkeleton app ver 3.0.3 with minimall packages
  2. nextinstall doctrine-module:1.2.0
    composer require doctrine/doctrine-module:1.2.0
  3. next doctrine-orm-module 1.1.8
    composer require doctrine/doctrine-orm-module:1.1.8

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
Остальные варианты вызывают конфликты пакетов. У меня только так установилось.

ControllerFactory

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,
    ]
],

fix file encoding

The file encoding was set to UTF-8 (with BOM) instead of UTF-8 (without BOM).

Admin dashboard implementation

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

Console scripts

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...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.