{"id":23631585,"url":"https://github.com/marcomilon/micro","last_synced_at":"2025-11-08T12:30:32.468Z","repository":{"id":62507915,"uuid":"108914364","full_name":"marcomilon/micro","owner":"marcomilon","description":"PHP router","archived":false,"fork":false,"pushed_at":"2019-02-25T22:03:09.000Z","size":58,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-28T03:17:12.982Z","etag":null,"topics":["composer","form-builder","framework-php","mvc","mvc-pattern","php","php-frameworks","php7"],"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/marcomilon.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":"2017-10-30T22:14:47.000Z","updated_at":"2022-06-15T12:09:46.000Z","dependencies_parsed_at":"2022-11-02T12:46:00.139Z","dependency_job_id":null,"html_url":"https://github.com/marcomilon/micro","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomilon%2Fmicro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomilon%2Fmicro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomilon%2Fmicro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcomilon%2Fmicro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcomilon","download_url":"https://codeload.github.com/marcomilon/micro/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239552765,"owners_count":19657983,"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":["composer","form-builder","framework-php","mvc","mvc-pattern","php","php-frameworks","php7"],"created_at":"2024-12-28T03:17:15.323Z","updated_at":"2025-11-08T12:30:32.402Z","avatar_url":"https://github.com/marcomilon.png","language":"PHP","readme":"# Micro\n\n[![Latest Stable Version](https://poser.pugx.org/fullstackpe/micro/v/stable)](https://packagist.org/packages/fullstackpe/micro) [![Build Status](https://travis-ci.org/marcomilon/micro.svg?branch=master)](https://travis-ci.org/marcomilon/micro)\n\nMicro is a lightweight PHP router.\n\n### Installation\n\nFirst you need to install Composer. You may do so by following the instructions at [getcomposer.org](https://getcomposer.org/download/). After that run\n\n\u003e composer require fullstackpe/micro\n\nIf you prefer you can create a composer.json in your project folder.\n\n```json\n{\n    \"require\": {\n        \"fullstackpe/micro\": \"^1.1\"\n    }\n}\n```\n\n### How it works?\n\nMicro use a php router. It matchs urls with PHP classes (Controllers).\n\n#### Directory structure\n\nTo use a url like this: **index.php?r=controllerName/viewName** your directory structure should be:\n\n```\n/controllers/\n    ControllerClass.php\n/views/\n    viewFile.php\n/web/\n    webassets \n    index.php\n```\n\nTo use a url like this: **index.php?r=moduleName/controllerName/viewName** your directory structure should be:\n\n```\n/modules/\n    modulesName1/\n        controllers/\n            ControllerClass.php\n        views/\n            viewFile.php \n    modulesName2/\n        controllers/\n            ControllerClass.php\n        views/\n            viewFile.php \n/web/\n    webassets \n    index.php\n```\n\nPlease be note that the only directory that needs to be public is the **web** directory.           \n\n#### Application \n\nThe Application class is the single point of entry. The constructor have one parameter as an array where you can pass configuration \nkey for example to setup a database connection. \n\nFor example:\n\n```php\n\u003c?php \n\n$config = [\n    'key' =\u003e 'Config value'\n];\n\n$app = new \\micro\\Application($config);\n$queryString = $_GET;\n$app-\u003erun($queryString);\n\n```\n\n\n#### Controllers\n\nControllers classes are stored in the controller directory and has to extends the core Controller class. A typical controller looks like this:\n\n```php\n\u003c?php \n\nnamespace app\\controller;\n\nuse micro\\Controller;\n\nclass CustomCtrl extends Controller\n{\n    public function index() \n    {\n        return $this-\u003erender('index');\n    }\n    \n    public function home($arg1, $arg2) \n    {\n        return $this-\u003erender('home', [\n            'arg1' =\u003e $arg1,\n            'arg2' =\u003e $arg2\n        ]);\n    }\n}\n\n```\n\n#### Views\n\nControllers are use for render views. Views are stored in a directory that has the \nsame name of the controller inside the view directory.\n\nThe render function has two parameters: the name of the view file and the variables to be rendered in the view. The function will search for a render file with name equals to its first argument. \n\nFor example\n\nControllers are use for render views. Views are stored in a directory with the \nsame name of the controller inside the view directory.\n\nThe render function has two parameters: the name of the view file and the variables to be rendered in the view. The function will search for a render file with name equals to its first argument. \n\nFor example\n\n```php\n\u003c?php \nreturn $this-\u003erender('home', [\n    'arg1' =\u003e $arg1,\n    'arg2' =\u003e $arg2\n]);\n\n```\nWill search for a view file named \"home\" in the controllers directory inside the\nview folder.\n\n#### Running Micro\n\nYou can run micro with php Built-in web server. Run the following command:\n\n\u003e php -S localhost:8080 -t web\n\nOpen localhost:8080 in your browser:\n\n\u003e http://localhost:8080\n\n#### Why [micro](https://en.wikipedia.org/wiki/Transport_in_Lima)?\n\nThe word micro is used in common-day Peruvian Spanish as an abbreviation for microbus (minibus). \nMicros race from one street corner to another along all the major arterial city roads. They run fast just like this framework.\n\n![alt text](https://raw.githubusercontent.com/marcomilon/micro-basic-app/master/web/img/micro.jpg)\n\n### Contribution\n\nFeel free to contribute! Just create a new issue or a new pull request.\n\n### License\n\nThis library is released under the MIT License.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcomilon%2Fmicro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcomilon%2Fmicro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcomilon%2Fmicro/lists"}