{"id":13669277,"url":"https://github.com/itsgoingd/slim-services","last_synced_at":"2025-03-17T03:31:42.081Z","repository":{"id":12920720,"uuid":"15598234","full_name":"itsgoingd/slim-services","owner":"itsgoingd","description":"Service manager for Slim compatible with Laravel packages","archived":false,"fork":false,"pushed_at":"2014-01-31T17:44:46.000Z","size":128,"stargazers_count":75,"open_issues_count":1,"forks_count":7,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-27T17:35:24.274Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itsgoingd.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-03T01:27:52.000Z","updated_at":"2024-05-20T10:17:14.000Z","dependencies_parsed_at":"2022-09-10T22:30:31.940Z","dependency_job_id":null,"html_url":"https://github.com/itsgoingd/slim-services","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-services","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-services/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-services/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-services/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsgoingd","download_url":"https://codeload.github.com/itsgoingd/slim-services/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841207,"owners_count":20356443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T08:01:08.350Z","updated_at":"2025-03-17T03:31:41.798Z","avatar_url":"https://github.com/itsgoingd.png","language":"PHP","funding_links":[],"categories":["PHP","Packages and Middleware"],"sub_categories":["Videos"],"readme":"SlimServices\n============\n\nSlimServices is a service manager for the [Slim PHP microframework](http://github.com/codeguy/slim) based on [Laravel 4](http://laravel.com) service providers and DI container, allowing you to use core and many third-party Laravel packages in Slim based projects.\n\nFor example, to add Eloquent ORM to your Slim app:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse SlimServices\\ServiceManager;\n\n$app = new Slim\\Slim(array(\n\t// paths\n\t'path' =\u003e __DIR__,\n\t// database\n    'database.fetch' =\u003e PDO::FETCH_CLASS,\n    'database.default' =\u003e 'main',\n    'database.connections' =\u003e array(\n        'main' =\u003e array(\n            'driver'    =\u003e 'mysql',\n            'host'      =\u003e '127.0.0.1',\n            'database'  =\u003e 'my_database',\n            'username'  =\u003e 'root',\n            'password'  =\u003e '',\n            'charset'   =\u003e 'utf8',\n            'collation' =\u003e 'utf8_unicode_ci',\n            'prefix'    =\u003e '',\n        ),\n    )\n));\n\n$services = new ServiceManager($app);\n$services-\u003eregisterServices(array(\n\t'Illuminate\\Events\\EventServiceProvider',\n\t'Illuminate\\Database\\DatabaseServiceProvider'\n));\n\n// Laravel database component is now available in Slim's DI container\n\n$app-\u003eget('/users', function()\n{\n\t$app-\u003erender('users.html', array(\n\t\t// Load user list using Laravel database fluent query builder\n\t\t'users' =\u003e $app-\u003edb-\u003etable('users')-\u003ewhere('active', 1)-\u003eget()\n\t));\n})\n\n$app-\u003erun();\n```\n\nYou can find more information about service providers in the [Laravel documentation](http://laravel.com/docs/ioc#service-providers).\n\n## Installation\n\nTo install the latest version simply add this to your `composer.json`:\n\n```javascript\n\"itsgoingd/slim-services\": \"dev-master\"\n```\n\nOnce the package is installed, you need to create a ServiceManager and register the services you'd like to use, configuration for the services is shared with the Slim instance itself:\n\n```php\nuse SlimServices\\Service;\n\n$app = new Slim(...);\n\n$services = new ServiceManager($app);\n$services-\u003eregisterServices(array(\n\t'Illuminate\\Events\\EventServiceProvider',\n\t'Illuminate\\Database\\DatabaseServiceProvider',\n\t'Illuminate\\Filesystem\\FilesystemServiceProvider',\n\t'Illuminate\\Translation\\TranslationServiceProvider',\n\t'Illuminate\\Validation\\ValidationServiceProvider',\n\t'Mailer\\MailerServiceProvider',\n\t'Upload\\UploadServiceProvider',\n\t...\n));\n```\n\nConfiguration examples for some popular components:\n\n### Illuminate/Database\n\n```javascript\n\"require\": {\n    \"slim/slim\": \"\u003e=2.3.0\",\n    \"itsgoingd/slim-services\": \"dev-master\",\n    \"illuminate/database\": \"4.1.*\"\n}\n```\n\n```php\nrequire 'vendor/autoload.php';\n\nuse SlimServices\\ServiceManager;\n\n$app = new Slim\\Slim(array(\n\t// paths\n\t'path' =\u003e __DIR__,\n\t// database\n    'database.fetch' =\u003e PDO::FETCH_CLASS,\n    'database.default' =\u003e 'main',\n    'database.connections' =\u003e array(\n        'main' =\u003e array(\n            'driver'    =\u003e 'mysql',\n            'host'      =\u003e '127.0.0.1',\n            'database'  =\u003e 'my_database',\n            'username'  =\u003e 'root',\n            'password'  =\u003e '',\n            'charset'   =\u003e 'utf8',\n            'collation' =\u003e 'utf8_unicode_ci',\n            'prefix'    =\u003e '',\n        ),\n    )\n));\n\n$services = new ServiceManager($app);\n$services-\u003eregisterServices(array(\n\t'Illuminate\\Events\\EventServiceProvider',\n\t'Illuminate\\Database\\DatabaseServiceProvider'\n));\n\n$users = $app-\u003edb-\u003etable('users')-\u003eselect('login')-\u003eget();\n\nclass User extends Illuminate\\Database\\Eloquent\\Model { public $table = 'users'; }\n\n$users = User::all();\n```\n\n### Illuminate/Validation\n\n```javascript\n\"require\": {\n    \"slim/slim\": \"\u003e=2.3.0\",\n    \"itsgoingd/slim-services\": \"dev-master\",\n\t\"illuminate/validation\": \"4.1.*\",\n    \"illuminate/filesystem\": \"4.1.*\",\n    \"illuminate/translation\": \"4.1.*\"\n}\n```\n\n```php\nrequire 'vendor/autoload.php';\n\nuse SlimServices\\ServiceManager;\n\n$app = new Slim\\Slim(array(\n\t// paths\n\t'path' =\u003e __DIR__,\n\t// app\n\t'app.locale' =\u003e 'en'\n));\n\n$services = new ServiceManager($app);\n$services-\u003eregisterServices(array(\n\t'Illuminate\\Filesystem\\FilesystemServiceProvider',\n\t'Illuminate\\Translation\\TranslationServiceProvider',\n\t'Illuminate\\Validation\\ValidationServiceProvider'\n));\n\n$validator = $app-\u003evalidator-\u003emake(\n    array(\n        'name' =\u003e 'Igor',\n        'password' =\u003e 'noname',\n        'email' =\u003e 'igor@no.name'\n    ),\n    array(\n        'name' =\u003e 'required',\n        'password' =\u003e 'required|min:8',\n        'email' =\u003e 'required|email|unique:users'\n    )\n);\n\nif ($validator-\u003efails()) { ... }\n```\n\n### Custom service providers\n\nYou can create custom service providers simply by extending the `Illuminate\\Support\\ServiceProvider` class and registering them with the ServiceManager.\n\n```php\nclass MailerServiceProvider extends Illuminate\\Support\\ServiceProvider\n{\n\tpublic function register()\n\t{\n\t\t$this-\u003eapp-\u003ebindShared('mailer', function($app)\n\t\t{\n\t\t\treturn new Mailer($app['config']);\n\t\t});\n\t}\n}\n\n$services-\u003eregisterServices(array(\n\t...,\n\t'MailerServiceProvider'\n));\n\n$app-\u003emailer-\u003esend(...);\n```\n\n## Licence\n\nCopyright (c) 2014 Miroslav Rigler\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsgoingd%2Fslim-services","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsgoingd%2Fslim-services","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsgoingd%2Fslim-services/lists"}