Skip to content
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
Merged

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

merged 2 commits into from
Apr 11, 2017

Conversation

sergeyklay
Copy link
Contributor

@sergeyklay sergeyklay commented Apr 11, 2017

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 sergeyklay merged commit 4538b42 into phalcon:3.2.x Apr 11, 2017
@sergeyklay sergeyklay deleted the feature/service-from-config branch April 11, 2017 21:49
@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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant