{"id":18520125,"url":"https://github.com/php-di/demo","last_synced_at":"2025-04-07T09:20:38.729Z","repository":{"id":2075727,"uuid":"36674007","full_name":"PHP-DI/demo","owner":"PHP-DI","description":"Demo of a simple application built using PHP-DI","archived":false,"fork":false,"pushed_at":"2022-04-29T11:07:54.000Z","size":109,"stargazers_count":216,"open_issues_count":0,"forks_count":134,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-31T07:09:00.251Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PHP-DI.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-06-01T16:37:07.000Z","updated_at":"2025-01-06T17:56:07.000Z","dependencies_parsed_at":"2022-08-07T23:30:08.661Z","dependency_job_id":null,"html_url":"https://github.com/PHP-DI/demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2Fdemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2Fdemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2Fdemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-DI%2Fdemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHP-DI","download_url":"https://codeload.github.com/PHP-DI/demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247622983,"owners_count":20968575,"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-11-06T17:18:40.844Z","updated_at":"2025-04-07T09:20:38.691Z","avatar_url":"https://github.com/PHP-DI.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP-DI application demo\n\nThis repository demonstrates how to write a simple application using PHP-DI without any framework.\n\n## Screenshot\n\n![](screenshot.png)\n\n## Disclaimer\n\nWatch out, this project is meant to show how to build an application from scratch with PHP-DI in the simplest way possible. Be aware that this code is only meant for learning purposes and should probably not go to production as-is.\n\nImprovements and pull requests are welcome.\n\n## Run\n\nTo run this demo, you need to clone it and install dependencies:\n\n```\ngit clone https://github.com/PHP-DI/demo.git\ncd demo/\ncomposer install\n```\n\nYou can then run the web application using PHP's built-in server:\n\n```\nphp -S 0.0.0.0:8000 -t web/\n```\n\nThe web application is running at [http://localhost:8000](http://localhost:8000/).\n\nYou can also run the CLI application:\n\n```\nphp console.php\n```\n\nThe following commands are available:\n\n- `php console.php articles`: lists the blog articles\n- `php console.php article [id]`: displays a blog article by its ID\n\n## Architecture\n\nThe container is created in [app/bootstrap.php](app/bootstrap.php). The configuration file for the container is [app/config.php](app/config.php).\n\nBoth the web application and the CLI application require `app/bootstrap.php` to get the container:\n\n- the web application ([web/index.php](web/index.php)) uses [FastRoute](https://github.com/nikic/FastRoute) for routing, and then creates and invokes the controller using PHP-DI\n- the CLI application ([console.php](console.php)) uses [Silly](http://mnapoli.fr/silly/): Silly uses the container to create and invoke the commands\n\nYou will note that in both case, the controllers/commands are instantiated and invoked by PHP-DI: this is to benefit from dependency injection in those classes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-di%2Fdemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-di%2Fdemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-di%2Fdemo/lists"}