{"id":28231195,"url":"https://github.com/iazaran/php-mvc","last_synced_at":"2025-10-05T04:02:18.779Z","repository":{"id":37080783,"uuid":"225574438","full_name":"iazaran/php-mvc","owner":"iazaran","description":"PHP MVC ⦿ Dockerized • Composer • RESTful API • Memcached • cron • WebSocket • Xdebug • OPcache","archived":false,"fork":false,"pushed_at":"2025-09-14T09:45:22.000Z","size":624,"stargazers_count":22,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-14T11:39:42.778Z","etag":null,"topics":["api","composer","cron","docker","memcached","mvc","opcache","php","websocket","xdebug"],"latest_commit_sha":null,"homepage":"","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/iazaran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-12-03T08:59:05.000Z","updated_at":"2025-09-14T09:45:21.000Z","dependencies_parsed_at":"2023-01-29T00:16:17.759Z","dependency_job_id":"8e572235-67f8-4509-aa0c-44979f2b0692","html_url":"https://github.com/iazaran/php-mvc","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/iazaran/php-mvc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iazaran%2Fphp-mvc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iazaran%2Fphp-mvc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iazaran%2Fphp-mvc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iazaran%2Fphp-mvc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iazaran","download_url":"https://codeload.github.com/iazaran/php-mvc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iazaran%2Fphp-mvc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278406690,"owners_count":25981658,"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-10-05T02:00:06.059Z","response_time":54,"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":["api","composer","cron","docker","memcached","mvc","opcache","php","websocket","xdebug"],"created_at":"2025-05-18T18:19:44.675Z","updated_at":"2025-10-05T04:02:18.763Z","avatar_url":"https://github.com/iazaran.png","language":"PHP","readme":"### Dockerized Pure PHP Composer based MVC Framework\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/8d638fe590dd4e68b9ce4ac9a7517e3d)](https://app.codacy.com/gh/iazaran/php-mvc/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n\n\u003e This project tries to cover some PHP features in a simple MVC structure with minimum installed composer packages. Then developers can use packages for specific requirements. Please add your ideas in Discussions, ask features or report bugs in issues.\n\n#### Features:\n**List of features related with structure**\n- **public**\nContains the index.php file, to start application and configures auto-loading. Different server configurations added into this directory too. Finally, you can find the Sitemap generator that runs after creation or updating a post.\n- **public/assets**\nAssets can contain your media files like images, audios \u0026 videos.\n- **public/css** \u0026 **public/js**\nContains the styles \u0026 scripts _(After changes on these files, you can use minifier script to update minified versions, just run `docker-compose exec php-mvc-app php minifier.php`)_\n- **public/feed**\nThere is a RSS generator in here and runs after creation or updating a post.\n- **grpc**\nA simple router for distribute the requests to different services. It is not working yet and I created an issue for it ⚠ and if you have an idea or a solution, only by PHP for both server and client sides, please add your solution in there.\n- **websocket**\nA WebSocket sample. You can open /websocket route in 2 tabs and test the websocket connection.\n- **src**\nContains migrations for a DB and routes.\n- **src/App**\nContains all classes that used in codes like PDO, Middleware, Router \u0026 ...\n- **src/Console**\nContains all scripts to run multiple times via Cron Jobs _(Scripts should be registered in /commands.php with custom timing, they will run by independent service in docker-compose)_\n- **src/Controllers**\nControllers related with your routes separated for web and API. API folder includes both RESTful API and gRPC API. If you want use gRPC _(gRPC client \u0026 server are not completed, and I ignored them for now. So be careful about the bugs in gRPC ⚠ and if you have an idea or a solution, only by PHP, please make a new discussion/issue/PR)_, you can find .proto file in API folder. Updating it will need to generate PHP codes again by\n```\ndocker-compose exec php-mvc-app protoc -I=src/Controllers/API \\\n    src/Controllers/API/blog.proto \\\n    --php_out=src/Controllers/API/gRPC \\\n    --grpc_out=src/Controllers/API/gRPC \\\n    --plugin=protoc-gen-grpc=/usr/bin/grpc_php_plugin\n```\n- **src/Models**\nModels related with controllers' DB queries \u0026 requirements.\n- **src/Views**\nSimple PHP files to show data on Frontend with reusable include files.\n- **/**\nYou can update env variables and composer.json to add custom packages.\n\n#### Useful Functions:\n- **XmlGenerator::feed()**\nGenerate sitemap.xml \u0026 rss.xml via a script file\n- **HandleForm::upload(...)**\nUpload file, resize image \u0026 add watermark\n- **HandleForm::validate(...)**\nValidation rules\n- **HandleFile::write(...)** \u0026 **HandleFile::read(...)**\nWrite into and read from file\n- **Helper::mailto(...)**\nSend HTML Email\n- **Helper::dd(...)**\nDumps a given variable along with some additional data\n- **Helper::log(...)**\nLogging custom data into file\n- **Helper::csrf(...)**\nCheck Cross-site request forgery token\n- **Helper::slug(...)**\nSlugging string to make user-friendly URL\n- **Cache::checkCache(...)**, **Cache::cache(...)** \u0026 **Cache::clearCache(...)**\nCheck existing cache, cache data and clear cache, by Memcached\n- **UserInfo::current()**\nReturn current user information\n- **UserInfo::info(...)**\nReturn selected user information\n- **Event::listen(...)** \u0026 **Event::trigger(...)**\nRegister an event listener and trigger it when needed\n- **R::runScript(...)**\nRun R script (if you have R installed)\n- **HttpClient::cURL(...)**\nRun cURL script to send a request\n- **CsvGenerator::exportCSV(...)**\nExport a specific table from DB to a CSV file\n\n#### Run Web App:\n- Install docker and docker-compose if needed\n- Uncomment `// createTables();` in `src/routes`\n- Run `docker-compose up --build -d`\n- Open your browser and open web app in `localhost:8080` _(It will create tables related with migrations.php and then will comment `createTables();` automatically.)_\n- You can run any command via Docker container like `docker exec -it php-mvc-app composer update`\n- You can run `docker-compose down` to stop and remove containers\n- Next time you can use `docker-compose up -d`\n\n#### Use Ajax to send forms' data:\nConsider a route for your form like `/blog/create`; now use `blog-create` as an ID for form, and `blog-create-submit` for submit button ID. All form's buttons need to have constant `form-button` class.\n\n#### Use Xdebug:\nXdebug installed via Docker, so it is ready to use, just need to start debug in your IDE or start listening to the Xdebug.\n\n#### RESTful API sample\n\n```php\n$curl = curl_init();\n\ncurl_setopt_array($curl, array(\n    CURLOPT_PORT =\u003e \"8080\",\n    CURLOPT_URL =\u003e \"http://localhost:8080/api/blog/create\",\n    CURLOPT_RETURNTRANSFER =\u003e true,\n    CURLOPT_MAXREDIRS =\u003e 10,\n    CURLOPT_TIMEOUT =\u003e 30,\n    CURLOPT_HTTP_VERSION =\u003e CURL_HTTP_VERSION_1_1,\n    CURLOPT_CUSTOMREQUEST =\u003e \"POST\",\n    CURLOPT_POSTFIELDS =\u003e \"{\\n\\t\\\"category\\\": \\\"Laravel\\\",\\n\\t\\\"title\\\": \\\"Laravel 6.7.0 Released\\\",\\n\\t\\\"subtitle\\\": \\\"The Laravel team released a minor version v6.7.0 this week, with the latest features, changes, and fixes for 6.x\\\",\\n\\t\\\"body\\\": \\\"\u0026lt;p style=\\\\\\\"box-sizing: inherit; border: 0px solid; margin: 0px 0px 1.875rem; color: rgb(82, 82, 82); font-family: %26quot;Source Sans Pro%26quot;, system-ui, BlinkMacSystemFont, -apple-system, %26quot;Segoe UI%26quot;, Roboto, Oxygen, Ubuntu, Cantarell, %26quot;Fira Sans%26quot;, %26quot;Droid Sans%26quot;, %26quot;Helvetica Neue%26quot;, sans-serif; font-size: 20px; background-color: rgb(255, 255, 255);\\\\\\\"\u003eThe Laravel team released a minor version v6.7.0 this week, with the latest features, changes, and fixes for 6.x:\u0026lt;/p\u0026gt;\\\",\\n\\t\\\"position\\\": \\\"2\\\"\\n}\",\n    CURLOPT_HTTPHEADER =\u003e array(\n        \"Authorization: Bearer qwaeszrdxtfcygvuhbijnokmpl0987654321\",\n        \"Content-Type: application/javascript\"\n    ),\n));\n\n$response = curl_exec($curl);\n$err = curl_error($curl);\ncurl_close($curl);\nif ($err) {\n    echo \"cURL Error #:\" . $err;\n} else {\n    echo $response;\n}\n```\n\n------------\nLet me know about collaborating:\n[eazaran@gmail.com](mailto:eazaran@gmail.com \"eazaran@gmail.com\")\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiazaran%2Fphp-mvc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiazaran%2Fphp-mvc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiazaran%2Fphp-mvc/lists"}