{"id":13669596,"url":"https://github.com/lastguest/mu","last_synced_at":"2025-04-27T04:33:50.968Z","repository":{"id":4651825,"uuid":"5797427","full_name":"lastguest/mu","owner":"lastguest","description":"A tweet-sized PHP micro-router","archived":false,"fork":false,"pushed_at":"2017-09-22T13:17:27.000Z","size":17,"stargazers_count":233,"open_issues_count":0,"forks_count":15,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-08-02T08:08:30.732Z","etag":null,"topics":["lightweight","micro-framework","php","router"],"latest_commit_sha":null,"homepage":"","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/lastguest.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2012-09-13T16:20:24.000Z","updated_at":"2024-07-31T16:34:26.000Z","dependencies_parsed_at":"2022-07-14T10:48:40.014Z","dependency_job_id":null,"html_url":"https://github.com/lastguest/mu","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/lastguest%2Fmu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastguest%2Fmu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastguest%2Fmu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lastguest%2Fmu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lastguest","download_url":"https://codeload.github.com/lastguest/mu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224060375,"owners_count":17249013,"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":["lightweight","micro-framework","php","router"],"created_at":"2024-08-02T08:01:18.506Z","updated_at":"2024-11-11T06:30:34.579Z","avatar_url":"https://github.com/lastguest.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# µ\n\na PHP micro URL router in only 140 bytes. (99 bytes in *hardcore* branch)\n\n[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/lastguest/mu/badges/quality-score.png?s=e29b47be8993b94957e9e6e9f37edd6184f6c753)](https://scrutinizer-ci.com/g/lastguest/mu/)\n\n**Warning: This is a pure proof of concept of a tweet-sized URL router**\n\n**DO NOT USE IT IN PRODUCTION!**\n\n```php\nclass µ{static function __callStatic($n,$a){static$r;$n==@_?($_=@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)])\u0026\u0026$_():$r[$n.$a[0]]=$a[1];}}\n```\n\n### How to use\n\n**Step 1:** Define routes callbacks\n\n```php\nµ::GET('/',function(){\n    echo 'What is your name?';\n    echo '\u003cform method=post\u003e\u003cinput type=text name=username\u003e\u003cinput type=submit\u003e\u003c/form\u003e';\n});\n```\n\t\n```php\nµ::POST('/',function(){\n    echo 'Hello ',$_POST['username'],', how are you?';\n});\n```\n\n**Step 2:** Run the app\n\t\n```php\nµ::_();\n```\n\n**Step 3:** Breath.\n\n## Thanks\n[celtric](https://github.com/celtric)\n\n[David Pennington (Xeoncross)](https://github.com/Xeoncross)\n\n[Tyler Romeo (Parent5446)](https://github.com/Parent5446)\n\n\n## Commented source\n\n```php\n\nclass µ {\n    public static function __callStatic($functionName,$functionParameters){\n        static $callbackMap;\n        \n        // Check if we must resolve the request\n        if($functionName == '_'){\n        \n            // Compose the method+uri key and\n            // invoke the callback (silence failures)\n        \n            ($callback = @$callbackMap[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]) \u0026\u0026 $callback();\n        \n        } else {\n        \n            // Add the route handler to the callbackMap\n            // $functionName is the Request HTTP Method\n            // $functionParameters[0] is the route\n            // $functionParameters[1] is the callback\n        \n            $callbackMap[$functionName.$functionParameters[0]] = $functionParameters[1];\n        }\n    }\n}\n```\n\n\n## License (MIT)\n\nCopyright (c) 2012 Stefano Azzolini\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\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\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n\n[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/lastguest/mu/trend.png)](https://bitdeli.com/free \"Bitdeli Badge\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flastguest%2Fmu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flastguest%2Fmu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flastguest%2Fmu/lists"}