{"id":19529145,"url":"https://github.com/riverside/php-express","last_synced_at":"2025-07-08T22:03:43.240Z","repository":{"id":62536067,"uuid":"181546058","full_name":"riverside/php-express","owner":"riverside","description":":horse: PHP micro-framework inspired by Express.js","archived":false,"fork":false,"pushed_at":"2024-09-23T10:25:35.000Z","size":616,"stargazers_count":34,"open_issues_count":5,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T22:02:43.203Z","etag":null,"topics":["application","controller","express","expressjs","micro-framework","php","php-framework","php-router","router","view","viewcontroller","web-framework","webapp"],"latest_commit_sha":null,"homepage":"https://riverside.github.io/php-express/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riverside.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://www.paypal.me/Dimitar81"}},"created_at":"2019-04-15T18:43:00.000Z","updated_at":"2025-03-30T22:04:12.000Z","dependencies_parsed_at":"2024-11-18T02:03:12.963Z","dependency_job_id":"d888a928-41d1-48a0-ba7e-ca6b7ecdea1d","html_url":"https://github.com/riverside/php-express","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/riverside/php-express","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-express","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-express/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-express/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-express/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riverside","download_url":"https://codeload.github.com/riverside/php-express/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-express/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264357293,"owners_count":23595575,"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":["application","controller","express","expressjs","micro-framework","php","php-framework","php-router","router","view","viewcontroller","web-framework","webapp"],"created_at":"2024-11-11T01:22:14.463Z","updated_at":"2025-07-08T22:03:43.223Z","avatar_url":"https://github.com/riverside.png","language":"PHP","readme":"# php-express\nPHP micro-framework inspired by Express.js\n\n| Build | GitHub pages | Stable | License |\n| --- | --- | --- | --- |\n| [![CI](https://github.com/riverside/php-express/actions/workflows/test.yml/badge.svg)](https://github.com/riverside/php-express/actions/workflows/test.yml) | [![pages-build-deployment](https://github.com/riverside/php-express/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/riverside/php-express/actions/workflows/pages/pages-build-deployment) | [![Latest Stable Version](https://poser.pugx.org/riverside/php-express/v/stable)](https://packagist.org/packages/riverside/php-express) | [![License](https://poser.pugx.org/riverside/php-express/license)](https://packagist.org/packages/riverside/php-express) |\n\n### Requirements\n- PHP \u003e= 7.1\n- PHP extensions:\n  - JSON (`ext-json`)\n\n### Installation\nIf Composer is not installed on your system yet, you may go ahead and install it using this command line:\n```\n$ curl -sS https://getcomposer.org/installer | php\n```\nNext, add the following require entry to the \u003ccode\u003ecomposer.json\u003c/code\u003e file in the root of your project.\n```json\n{\n    \"require\" : {\n        \"riverside/php-express\" : \"^2.0\"\n    }\n}\n```\nFinally, use Composer to install php-express and its dependencies:\n```\n$ php composer.phar install \n```\n### Routing\n```php\n\u003c?php\n$app = new \\Riverside\\Express\\Application();\n\n$app-\u003eget('/', function ($req, $res) {\n     $res-\u003esend('hello world');\n});\n```\n#### Route methods\n```php\n\u003c?php\n// GET method route\n$app-\u003eget('/', function ($req, $res) {\n    $res-\u003esend('GET request to the homepage');\n});\n\n// POST method route\n$app-\u003epost('/', function ($req, $res) {\n    $res-\u003esend('POST request to the homepage');\n});\n```\n#### Route paths\n```php\n\u003c?php\n$app-\u003eget('/', function ($req, $res) {\n    $res-\u003esend('root');\n});\n\n$app-\u003eget('about', function ($req, $res) {\n    $res-\u003esend('about');\n});\n\n$app-\u003eget('random.text', function ($req, $res) {\n    $res-\u003esend('random.text');\n});\n```\n\n#### Response methods\n| Method             | Description                       |\n| ------------------ | --------------------------------- |\n| $res-\u003eend()        | End the response process.         |\n| $res-\u003ejson()       | Send a JSON response.             |\n| $res-\u003eredirect()   | Redirect a request.               |\n| $res-\u003erender()     | Render a view template.           |\n| $res-\u003esend()       | Send a response of various types. |\n| $res-\u003esendStatus() | Set the response status code and send its string representation as the response body. |\n\n#### $app-\u003eroute()\n```php\n\u003c?php\n$app-\u003eroute('/book')\n    -\u003eget(function ($req, $res) {\n        $res-\u003esend('Get a random book');\n    })\n    -\u003epost(function ($req, $res) {\n        $res-\u003esend('Add a book');\n    })\n    -\u003eput(function ($req, $res) {\n        $res-\u003esend('Update the book');\n    });\n```\n\n#### Router\n```php\n\u003c?php\n$router = new \\Riverside\\Express\\Router($app);\n\n$router-\u003eparam('uuid', '[a-f\\d]{8}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{4}-[a-f\\d]{12}');\n\n$router-\u003eget('/', function ($req, $res) {\n    $res-\u003esend('Birds home page');\n});\n\n$router-\u003eget('about', function ($req, $res) {\n    $res-\u003esend('About birds');\n});\n\n$router-\u003eget('ticket/:uuid/', function($req, $res) {\n    echo $req-\u003eparams['uuid'];\n});\n\n$router-\u003erun();\n```\n#### Middleware\n```php\n$app-\u003euse(function($req, $res) {\n    $res-\u003eheader('X-Frame-Options', 'DENY');\n    $res-\u003eheader('X-Powered-By', false);\n});\n\n$app-\u003euse('/cors', function($req, $res) {\n    $res-\u003eheader('Access-Control-Allow-Origin', '*');\n});\n```","funding_links":["https://www.paypal.me/Dimitar81"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverside%2Fphp-express","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friverside%2Fphp-express","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverside%2Fphp-express/lists"}