{"id":18803092,"url":"https://github.com/nabeelalihashmi/apilot-engine","last_synced_at":"2026-01-05T11:30:16.882Z","repository":{"id":57023154,"uuid":"453040769","full_name":"nabeelalihashmi/Apilot-Engine","owner":"nabeelalihashmi","description":"Fast router for PHP","archived":false,"fork":false,"pushed_at":"2022-01-28T18:00:20.000Z","size":233,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-29T20:23:15.846Z","etag":null,"topics":["php","php-library","php-router","php-router-standalone","php-routing"],"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/nabeelalihashmi.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}},"created_at":"2022-01-28T11:22:09.000Z","updated_at":"2022-02-01T04:52:18.000Z","dependencies_parsed_at":"2022-08-23T12:20:45.283Z","dependency_job_id":null,"html_url":"https://github.com/nabeelalihashmi/Apilot-Engine","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FApilot-Engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FApilot-Engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FApilot-Engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeelalihashmi%2FApilot-Engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeelalihashmi","download_url":"https://codeload.github.com/nabeelalihashmi/Apilot-Engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239735259,"owners_count":19688262,"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":["php","php-library","php-router","php-router-standalone","php-routing"],"created_at":"2024-11-07T22:33:02.855Z","updated_at":"2026-01-05T11:30:16.823Z","avatar_url":"https://github.com/nabeelalihashmi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Apilot\nFast automatic files based router with Caching routes\n\n![alt text](./img/speed.png)\n\n### WARNING\nDesign api carefully\n\n## Installation\n\n### Using Composer\n```\n    composer require nabeelalihashmi/apilot-engine\n```\n### Manual\nJust download the `Apilot.php` file, include in your project. Configure `.htaccess`.\n\n```\n\u003c?php\n    $apilot = new Apilot($handlers_path, $cache_path, $optional_server_basepath);\n    $apiot-\u003eon404(function() {\n        ...\n    });\n    $apilot-\u003etakeoff();\n?\u003e\n\n```\n\n### .htaccess files\n\n- Copy extras/root.htaccess in root folder and rename it to .htaccess.\n- Copy extras/public.htaccess in public folder and rename it to .htaccess.\n## Routes\nMake a folder for handlers. Each file in that cockpit folder corresponds to a route.\n\ne.g.\n\n```\ncockpit/\n    index.php -\u003e /\n    about.php -\u003e /about\n    contact.php -\u003e contact\n    ...\n\n```\n\nEach file must have at least one handler method. The name of the method must be `handle`.\n\ne.g.\n\n```\n    function GET() {\n\n    }\n\n    function POST() {\n\n    }\n\n    function PUT() {\n\n    }\n    \n```\n\n## Dynamic routes\n\nTo make a route accept dynamic value, use `:` in the route.\n\ne.g.\n\n```\n    File: cockpit/users/:id/edit.php\n    URI: /users/:id/edit\n\n    function GET($id) {\n        ...\n    }\ns\n    File: cockpit/users/:id/:action.php\n    URI: /users/:id/:action\n\n    function GET($id, $action) {\n        ...\n    }\n\n```\n\n## Optional Parameters\n\nTo make a route optional, make the parameter optional with `?`.\n\n```\n    File: cockpit/list/:page?.php\n    URI: /list/:page?\n\n    function GET($page = 1) {\n        ...\n    }\n\n```\n## Rules\n\n* Optional Routes must place at end\n```\nhello/:who? Good\nhello/:who?/level2 Bad\nhello/:who?/level2 Bad\n\n```\n\n## Middleware\n\nYou can use middleware to do something before and after the route. You can use `before` and `after` appended to handler method name. before middleware must return true to continue.\n\n```\nfunction GET() {\n\n}\n\nfunction before_GET() {\n    return true;\n}\n\nfunction after_GET() {\n\n}\n```\n\n## Route Not Found\n\nApilot will call the `on404` function if the route is not found. You can use this function to redirect to 404 page or do something else.\n\nusage:\n\n```\n$apilot-\u003eon404(function() {\n    ...\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeelalihashmi%2Fapilot-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeelalihashmi%2Fapilot-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeelalihashmi%2Fapilot-engine/lists"}