Skip to content

Instantly share code, notes, and snippets.

@sagikazarmark
Created January 30, 2015 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagikazarmark/490f37c98eb59b09015b to your computer and use it in GitHub Desktop.
Save sagikazarmark/490f37c98eb59b09015b to your computer and use it in GitHub Desktop.
Generic service provider
<?php
class SomeServiceProvider
{
public $provides = array(
'service',
'service.one',
'service.two',
);
public function provide()
{
$this->container->add('service', 'Service');
$this->container->add('service.one', 'Service1');
$this->container->add('service.two', 'Service2');
}
}
@hannesvdvreken
Copy link

I'd make provides a method.

<?php

class SomeServiceProvider
{
    public function provides function()
    {
        return [
            'service',
            'service.one',
            'service.two',
        ];
    }

    public function provide()
    {
        $this->container->add('service', 'Service');
        $this->container->add('service.one', 'Service1');
        $this->container->add('service.two', 'Service2');
    }
}

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