{"id":15563433,"url":"https://github.com/stefanotorresi/frameworkless-php-boilerplate","last_synced_at":"2025-08-01T23:05:02.072Z","repository":{"id":50252244,"uuid":"188871361","full_name":"stefanotorresi/frameworkless-php-boilerplate","owner":"stefanotorresi","description":"Framework-less PHP web application boilerplate","archived":false,"fork":false,"pushed_at":"2023-04-24T22:49:42.000Z","size":84,"stargazers_count":12,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-24T04:05:40.553Z","etag":null,"topics":[],"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/stefanotorresi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-27T15:49:49.000Z","updated_at":"2024-07-27T01:08:47.000Z","dependencies_parsed_at":"2025-04-23T23:28:27.068Z","dependency_job_id":"fc90fc04-de16-4cb8-a218-582b185b0860","html_url":"https://github.com/stefanotorresi/frameworkless-php-boilerplate","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/stefanotorresi/frameworkless-php-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanotorresi%2Fframeworkless-php-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanotorresi%2Fframeworkless-php-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanotorresi%2Fframeworkless-php-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanotorresi%2Fframeworkless-php-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanotorresi","download_url":"https://codeload.github.com/stefanotorresi/frameworkless-php-boilerplate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanotorresi%2Fframeworkless-php-boilerplate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268310706,"owners_count":24230181,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-02T16:22:31.220Z","updated_at":"2025-08-01T23:05:02.047Z","avatar_url":"https://github.com/stefanotorresi.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":["Examples"],"readme":"# ToDo API\n\n## Table of Contents\n\n- [Design](#design)\n  - [Infrastructure](#infrastructure)\n- [First run](#first-run)\n  - [Dev tools](#dev-tools)\n- [Configuration](#configuration)\n\n## Design\n\nThe project is a PHP framework-less web application based on [PSR-7](https://www.php-fig.org/psr/psr-7/), [PSR-11](https://www.php-fig.org/psr/psr-11/) and [PSR-15](https://www.php-fig.org/psr/psr-15/) standard interfaces.\n\nThe main third party libraries used as building blocks are:\n- [`zendframweork/zend-diactoros`](https://github.com/zendframework/zend-diactoros) for the PSR-7 HTTP messages;\n- [`league/route`](https://github.com/thephpleague/route) for a PSR-15 HTTP router;\n- [`php-di/php-di`](https://github.com/PHP-DI/PHP-DI) for a PSR-11 Dependency Injection container.\n\nThis allows for a very clean architecture with a straightforward lifecycle:\n1. bootstrap the application\n2. instantiate a request\n3. the application processes the request, producing a response\n4. the response is emitted\n\nThe application composes a PSR-15 middleware pipeline, the main middleware being the router, which forwards the request to the appropriate HTTP handler (see [src/Http/RouteHandler](src/Http/RouteHandler)).\n\nThe handlers themselves interact with the core domain model, which is a simple DBAL for the CRUD operations.\n\nThe resulting overall design is much simpler than a run-of-the-mill MVC framework application.\n\nThe storage backend is abstracted by a very simple DataMapper implementation built upon the native PDO extension.\n\nThe API itself is specified with the OpenAPI 3.0 standard (see [todos.openapi.yml](docs/todos.openapi.yml)), and user readable docs are generated on the fly.\n\nAdditional features like HTTP authentication and content negotiation are implemented via middleware.\n\nA small CLI is provided to remove some toil.\n\n### Infrastructure\n\nThe container setup has its main entry point in the reverse proxy service (NGINX).\n\nRequests are forwarded to the `index.php` file by explicitly setting FASTCGI parameters, and this allows to get entirely rid of the document root in the main application container.\n\nThe main [Dockerfile](Dockerfile) produces a production-ready, multi-stage image, and the provided `docker-compose.yml` file uses the `dev` stage, which includes development tools like `phpunit`, `php-cs-fixer`, `phpstan` and others.\n\nThe HTTP reverse proxy also forwards requests in the `/docs` path to a `swagger-ui` instance. \n\nHTTPS traffic is not provided, as something like this would probably live behind a TLS terminating LB.\n\nA GitLab CI configuration has been included, because I'm very used to CI and I quickly get bothered to run all the checks manually... ;)\n\n\n## First run\n\nSimply spin it up with `docker-compose`, wait for the database to be ready, and and create a database schema with the provided CLI:\n\n```\ndocker-compose up -d\ndocker-compose exec app wait-for database:5432\ndocker-compose exec app cli create-schema\n```\n\nThe application will be exposed at [http://localhost](http://localhost).  \nAPI docs can be reached at [http://localhost/docs](http://localhost/docs).\n\n### Dev tools\n\nThere are two suites of tests provided, plus configurations for coding style enforcement and static analysis.\n\n```\ndocker-compose exec app phpunit --testsuite unit\ndocker-compose exec app phpunit --testsuite integration\ndocker-compose exec app phpstan analyse src test\ndocker-compose exec app php-cs-fixer fix\n```\n\nNote: the integration tests will wipe out the database!\n\n### Configuration\n\nConfiguration is performed via the environment variables, which should be loaded into the app container with `docker-compose`.\n\n[Defaults](.env.example) are provided so that everything should work out of the box.\n\nFurther customization can be done by providing a `docker-compose.override.yml` file, which is ignored by the VCS.\n\nFor example:\n```yaml\n# docker-compose.override.yml\nversion: '3.7'\nservices:\n  app:\n    environment:\n      - DEBUG=false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanotorresi%2Fframeworkless-php-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanotorresi%2Fframeworkless-php-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanotorresi%2Fframeworkless-php-boilerplate/lists"}