New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Di::loadFromYaml and Di::loadFromPhp #12784

Merged
merged 2 commits into from Apr 11, 2017

Conversation

Projects
None yet
1 participant
@sergeyklay
Member

sergeyklay commented Apr 11, 2017

  • Type: new feature
  • Link to issue: #12517

Phalcon\Di::loadFromYaml

Loads services from a yaml file.

$di->loadFromYaml(
    "path/services.yaml",
    [
        "!approot" => function ($value) {
            return dirname(__DIR__) . $value;
        }
    ]
);

And the services can be specified in the file as:

myComponent:
    className: \Acme\Components\MyComponent
    shared: true

group:
    className: \Acme\Group
    arguments:
        - type: service
          name: myComponent

user:
   className: \Acme\User

Phalcon\Di::loadFromPhp

Loads services from a php config file.

$di->loadFromPhp("path/services.php");

And the services can be specified in the file as:

return [
     'myComponent' => [
         'className' => '\Acme\Components\MyComponent',
         'shared' => true,
     ],
     'group' => [
         'className' => '\Acme\Group',
         'arguments' => [
             [
                 'type' => 'service',
                 'service' => 'myComponent',
             ],
         ],
     ],
     'user' => [
         'className' => '\Acme\User',
     ],
];

sergeyklay added some commits Apr 11, 2017

@sergeyklay sergeyklay merged commit 4538b42 into phalcon:3.2.x Apr 11, 2017

@sergeyklay sergeyklay deleted the sergeyklay:feature/service-from-config branch Apr 11, 2017

@sergeyklay sergeyklay added this to the 3.2.0 milestone Apr 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment