{"id":21892093,"url":"https://github.com/clagiordano/weblibs-mvc","last_synced_at":"2025-03-22T03:22:03.295Z","repository":{"id":27679611,"uuid":"31165840","full_name":"clagiordano/weblibs-mvc","owner":"clagiordano","description":"weblibs-mvc is an simple and lightweight php routing component.","archived":false,"fork":false,"pushed_at":"2018-08-21T22:45:47.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T00:26:09.258Z","etag":null,"topics":["mvc","php","routing","weblibs-mvc"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clagiordano.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-22T14:41:10.000Z","updated_at":"2019-03-27T15:10:50.000Z","dependencies_parsed_at":"2022-09-01T00:11:50.098Z","dependency_job_id":null,"html_url":"https://github.com/clagiordano/weblibs-mvc","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clagiordano%2Fweblibs-mvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clagiordano%2Fweblibs-mvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clagiordano%2Fweblibs-mvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clagiordano%2Fweblibs-mvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clagiordano","download_url":"https://codeload.github.com/clagiordano/weblibs-mvc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244900134,"owners_count":20528638,"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":["mvc","php","routing","weblibs-mvc"],"created_at":"2024-11-28T12:49:07.937Z","updated_at":"2025-03-22T03:22:03.270Z","avatar_url":"https://github.com/clagiordano.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"![BuildStatus](https://travis-ci.org/clagiordano/weblibs-mvc.svg?branch=master) ![License](https://img.shields.io/github/license/clagiordano/weblibs-mvc.svg)\n\n# weblibs-mvc\nweblibs-mvc is an simple and lightweight php routing component.\nThis component can have a RESTful support simply adding an *.htaccess* file, see below for more details.\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/336cc1e2-157e-456c-85ba-7f105683fb80/big.png)](https://insight.sensiolabs.com/projects/336cc1e2-157e-456c-85ba-7f105683fb80)\n\nBased on http://php-html.net/tutorials/model-view-controller-in-php/\u003cbr /\u003e\nBased on http://phpro.org/tutorials/Model-View-Controller-MVC.html#9\n\n## Description of the main components\n\n## Application\nThe application class is the main component wich handle and relates components between them.\n\n### Controller\nThe Controller is the C in MVC.\nThe base controller is a simple abstract class that defines the\nstructure of all controllers.\nBy including the registry here, the registry is available to all class\nthat extend from the base controller. An index() method has also been\nincluded in the base controller which means all controller classes that\nextend from it must have an index() method themselves.\n\n### Registry\nThe registry is an object where site wide variables can be stored without\nthe use of globals.\nBy passing the registry object to the controllers that need them,\nwe avoid pollution of the global namespace and render our variables safe.\nWe need to be able to set registry variables and to get them.\n\n### Routing\nThe router class is responsible for loading up the correct controller.\nIt does nothing else. The value of the controller comes from the URL.\n\n### Template\nThe templates themselves are basically HTML files with a little PHP embedded.\nDo not let the separation Nazi's try to tell you that you need to have full\nseparation of HTML and PHP.\nRemember, PHP is an embeddable scripting language.\nThis is the sort of task it is designed for and makes an efficient\ntemplating language. The template files belong in the views directory.\n\n## Installation\nThe recommended way to install weblibs-mvc is through [Composer](https://getcomposer.org).\n```bash\ncomposer require clagiordano/weblibs-mvc\n```\n\n### Adding RESTful support to destination project\nSimply add into yours project root a file named ***.htaccess*** \u003cbr /\u003e\n*(webserver must be allow override)* which contains the following lines:\n```apacheconf\nRewriteEngine on\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]\n```\n\nthis simple steps allow your application make RESTful calls like:\n\n```http\nhttp://www.example.com/clients/68563\nhttp://www.example.com/access/login\nhttp://www.example.com/chart/\nhttp://www.example.com/products/6574\n```\n\n## Usage\n\n```php\n/**\n * Composer autoload\n */\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n/**\n * Import required classes\n */\nuse clagiordano\\weblibs\\mvc\\Application;\nuse clagiordano\\weblibs\\mvc\\Registry;\nuse clagiordano\\weblibs\\mvc\\Router;\nuse clagiordano\\weblibs\\mvc\\Template;\n\n/**\n * Init base application\n * @var Application $application\n */\n$application = new Application();\n\n/**\n * Router setup\n */\n$application-\u003esetRouter(\n    new Router($application)\n);\n\n/**\n * set the path to the controllers directory\n */\n$application-\u003egetRouter()-\u003esetControllersPath(\n    __DIR__ . '/controllers'\n);\n\n/**\n * Template setup\n */\n$application-\u003esetTemplate(\n    new Template($application)\n);\n\n/**\n * load the controller / run the application\n */\n$application-\u003egetRouter()-\u003eloader();\n```\n\n## Legal\n*Copyright (C) Claudio Giordano \u003cclaudio.giordano@autistici.org\u003e*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclagiordano%2Fweblibs-mvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclagiordano%2Fweblibs-mvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclagiordano%2Fweblibs-mvc/lists"}