{"id":13669562,"url":"https://github.com/itsgoingd/slim-facades","last_synced_at":"2025-03-17T03:31:43.036Z","repository":{"id":12567564,"uuid":"15238039","full_name":"itsgoingd/slim-facades","owner":"itsgoingd","description":"\"Static\" interface for various Slim features","archived":false,"fork":false,"pushed_at":"2014-12-03T23:53:31.000Z","size":153,"stargazers_count":74,"open_issues_count":1,"forks_count":9,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-27T17:35:25.640Z","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":"2013-12-16T21:43:47.000Z","updated_at":"2022-05-12T06:35:43.000Z","dependencies_parsed_at":"2022-09-23T08:01:20.614Z","dependency_job_id":null,"html_url":"https://github.com/itsgoingd/slim-facades","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-facades","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-facades/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-facades/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsgoingd%2Fslim-facades/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsgoingd","download_url":"https://codeload.github.com/itsgoingd/slim-facades/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:17.452Z","updated_at":"2025-03-17T03:31:42.741Z","avatar_url":"https://github.com/itsgoingd.png","language":"PHP","funding_links":[],"categories":["PHP","Packages and Middleware"],"sub_categories":["Videos"],"readme":"SlimFacades\n===========\n\nSlimFacades is a collection of facades for [Slim PHP microframework](http://github.com/codeguy/slim), providing simple \"static\" interface for various Slim features.\n\nFor example, turn this:\n\n```php\n$app-\u003eget('/hello-world', function()\n{\n\t$app = Slim::getInstance();\n\t$app-\u003eview()-\u003edisplay('hello.html', array('name' =\u003e $app-\u003erequest()-\u003eget('name', 'world')));\n})\n```\n\nInto this:\n\n```php\nRoute::get('/hello-world', function()\n{\n\tView::display('hello.html', array('name' =\u003e Input::get('name', 'world')));\n})\n```\n\nThis library is based on the Laravel 4 Facade class, more info about facades in the [Laravel documentation](http://laravel.com/docs/facades).\n\n## Installation\n\nTo install latest version simply add it to your `composer.json`:\n\n```javascript\n\"itsgoingd/slim-facades\": \"dev-master\"\n```\n\nOnce the package is installed, you need to initialize the Facade class:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse SlimFacades\\Facade;\n\n$app = new Slim\\Slim();\n\n// initialize the Facade class\n\nFacade::setFacadeApplication($app);\nFacade::registerAliases();\n\n// now you can start using the facades\n\nConfig::set('debug', true);\n\nRoute::get('/hello/:name', function($name)\n{\n\tView::display('hello.html', array(\n\t\t'name' =\u003e Input::get('name', $name)\n\t));\n});\n\nApp::run();\n```\n\nFollowing facades are available:\n\n### App\n- facade for Slim instance and following additional methods:\n- _make($key)_ - returns $key from Slim's DI container\n\n```php\n$request = App::make('request');\nApp::flash('message', 'Som Kuli, ovladam kozmicku lod.');\nApp::halt();\n```\n\n### Config\n- facade for Slim instance and following additional methods:\n- _get($key)_ - returns value of _$app-\u003econfig($key)_\n- _set($key, $value = null)_ - calls _$app-\u003econfig($key, $value)_\n\n```php\n$debug = Config::get('debug');\nConfig::set('log.enable', true);\n```\n\n### Input\n- facade for Slim\\Http\\Request instance and following additional methods:\n- _file($name)_ - returns $_FILES[$name], or null if the file was not sent in the request\n\n```php\n$username = Input::get('username', 'default');\n$password = Input::post('password');\n$avatar = Input::file('avatar');\n```\n\n### Log\n- facade for Slim\\Log instance\n\n```php\nLog::info('Tomi Popovic predava miliony albumov po celom svete.');\nLog::debug('Okamizte na pozorovanie.');\n```\n\n### Request\n- facade for Slim\\Http\\Request instance\n\n```php\nif (Request::isAjax()) { ... }\n$host = Request::headers('host', 'localhost');\n$path = Request::getPath();\n```\n\n### Response\n- facade for Slim\\Http\\Response instance\n\n```php\nResponse::redirect('/success');\n```\n\n### Route\n- facade for Slim\\Router instance and following methods:\n- _map, get, post, put, patch, delete, options, group, any_ - calls the methods on Slim instance\n\n```php\nRoute::get('/users/new', 'UsersController:index');\nRoute::post('/users', 'UsersController:insert');\n```\n\n### View\n- facade for Slim\\View instance\n\n```php\nView::display('hello.html');\n$output = View::render('world.html');\n```\n\n### Custom facades\nYou can create a custom facades by extending `SlimFacades\\Facade` class.\n\n```php\nclass MyFacade extends SlimFacades\\Facade\n{\n\t// return the name of the component from the DI container\n\tprotected static function getFacadeAccessor() { return 'my_component'; }\n}\n```\n\nYou can register custom facades by passing the aliases to the _Facade::registerAliases()_ function.\n\n```php\nFacade::registerAliases(array(\n\t'App'      =\u003e 'SlimFacades\\App',\n\t'Config'   =\u003e 'SlimFacades\\Config',\n\t'Input'    =\u003e 'SlimFacades\\Input',\n//\t'Log'      =\u003e 'SlimFacades\\Log',\n\t'Log'      =\u003e 'CustomLogFacade',\n\t'Request'  =\u003e 'SlimFacades\\Request',\n\t'Response' =\u003e 'SlimFacades\\Response',\n\t'Route'    =\u003e 'SlimFacades\\Route',\n\t'View'     =\u003e 'SlimFacades\\View',\n));\n```\n\nNote that calling _Facade::registerAliases()_ with a list of aliases will register ONLY the specified facades, if you want to register default facades as well as custom ones, you can call the function two times, with and without the array argument.\n\n## Links\n\n- [SlimStatic](https://github.com/johnstevenson/slim-static) - alternative implementation with similar API, without dependency on Laravel components by [John Stevenson](https://github.com/johnstevenson)\n\n## Licence\n\nCopyright (c) 2013 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-facades","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsgoingd%2Fslim-facades","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsgoingd%2Fslim-facades/lists"}