{"id":19476682,"url":"https://github.com/biurad/flange","last_synced_at":"2025-04-25T14:32:24.403Z","repository":{"id":56969642,"uuid":"177059019","full_name":"biurad/flange","owner":"biurad","description":"A modern PSR fully compliant framework for web, with great performance","archived":false,"fork":false,"pushed_at":"2024-02-22T09:32:20.000Z","size":873,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T22:51:14.152Z","etag":null,"topics":["framework","micro","php","psr-11","psr-14","psr-15","psr-17","psr-7","rade","symfony"],"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/biurad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","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":{"patreon":"biurad","custom":["https://biurad.com/sponsor"]}},"created_at":"2019-03-22T02:37:01.000Z","updated_at":"2023-06-19T08:05:46.000Z","dependencies_parsed_at":"2023-01-25T14:31:04.353Z","dependency_job_id":"9da354f5-efaf-4229-a9d5-5fc2faa50540","html_url":"https://github.com/biurad/flange","commit_stats":{"total_commits":318,"total_committers":3,"mean_commits":106.0,"dds":0.06603773584905659,"last_synced_commit":"4d73b78b77f52899aa61a4818fe5d95731783565"},"previous_names":["divineniiquaye/php-rade"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fflange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fflange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fflange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biurad%2Fflange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biurad","download_url":"https://codeload.github.com/biurad/flange/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250834166,"owners_count":21494921,"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":["framework","micro","php","psr-11","psr-14","psr-15","psr-17","psr-7","rade","symfony"],"created_at":"2024-11-10T19:41:28.838Z","updated_at":"2025-04-25T14:32:19.380Z","avatar_url":"https://github.com/biurad.png","language":"PHP","funding_links":["https://patreon.com/biurad","https://biurad.com/sponsor"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# The PHP Flange Framework\n\n[![PHP Version](https://img.shields.io/packagist/php-v/biurad/flange.svg?style=flat-square\u0026colorB=%238892BF)](http://php.net)\n[![Latest Version](https://img.shields.io/packagist/v/biurad/flange.svg?style=flat-square)](https://packagist.org/packages/biurad/flange)\n[![Workflow Status](https://img.shields.io/github/workflow/status/biurad/flange/build?style=flat-square)](https://github.com/biurad/flange/actions?query=workflow%3Abuild)\n[![Code Maintainability](https://img.shields.io/codeclimate/maintainability/biurad/flange?style=flat-square)](https://codeclimate.com/github/biurad/flange)\n[![Coverage Status](https://img.shields.io/codecov/c/github/biurad/flange?style=flat-square)](https://codecov.io/gh/biurad/flange)\n[![Quality Score](https://img.shields.io/scrutinizer/g/biurad/flange.svg?style=flat-square)](https://scrutinizer-ci.com/g/biurad/flange)\n\n\u003c/div\u003e\n\n---\n\n**Flange** is an incredibly fast, compilable and scalable framework for [PHP][1] 8.0+ based on [PSR-7][2], [PSR-11][3], [PSR-14][4] and [PSR-15][5] with support for annotations/attributes, created by [Divine Niiquaye][@divineniiquaye].\n\nThis library is shipped with lots of features that suites developers needs in developing web applications. Flange is truly scalable, has less dependencies and has high performance.\n\n\u003eFlange v2.0 is in early stage development and is not recommended for production use.\n\n## 📦 Installation \u0026 Basic Usage\n\nThis project requires [PHP][1] 8.0 or higher. The recommended way to install, is via [Composer][6]. Simply run:\n\n```bash\n$ composer require biurad/flange 2.0.*\n```\n\nFlange is built based on [Flight Routing][7], [Biurad DI][8], [Symfony components][9] and [Biurad libraries][10]. Flange is a fully PSR complaint [PHP][1] framework, fully customizable and can even be used to develop from small to large projects:\n\n```php\nrequire_once __DIR__ . '/vendor/autoload.php';\n\n// Boot the application.\n$app = new Flange\\Application();\n\n// Add a route to application\n$app-\u003ematch('/hello/{name:\\w+}', to: fn (string $name): string =\u003e 'Hello ' . $app-\u003eescape()-\u003eescapeHtml($name));\n\n$extensions = [\n    [Flange\\Extensions\\CoreExtension::class, [__DIR__]],\n    // You can add more extensions here ...\n];\n\n//If you want to use extensions, here is an example:\n$app-\u003eloadExtensions($extensions, ['config' =\u003e '%project_dir%/config']);\n\n// You can set custom pages for caught exceptions, using default event dispatcher, or your custom event dispatcher.\n$app-\u003egetDispatcher()?-\u003eaddListener(Flange\\Events::EXCEPTION, new ErrorListener(), -8);\n\n$app-\u003erun();\n```\n\nWorking on a big project!, it is advisable to use the application's cacheable version. This gives you over 60% - 100% more performance than using the un-cacheable Application class with extensions.\n\n```php\nuse function Rade\\DI\\Loader\\{param, phpCode, wrap};\n\n$config = [\n    'cacheDir' =\u003e __DIR__ . '/caches',\n    'debug' =\u003e $_ENV['APP_DEBUG'] ?? false, // Set the debug mode environment\n];\n\n// Setup cache for application.\n$app = Flange\\AppBuilder::build(static function (Flange\\AppBuilder $creator): void {\n    // Add resource to re-compile if changes are made to this file.\n    $creator-\u003eaddResource(new FileResource(__FILE__));\n\n    // Adding routes requires the Rade\\DI\\Extensions\\RoutingExtension to be loaded.\n    // Routes should always be added before Rade\\DI\\Extensions\\RoutingExtension is booted, else it will not be compiled.\n    $creator-\u003ematch('/hello/{name:\\w+}', to: phpCode('fn (string $name): string =\u003e \\'Hello \\' . $this-\u003eescape()-\u003eescapeHtml($name);'));\n\n    $extensions = [\n        [Flange\\Extensions\\CoreExtension::class, [__DIR__]],\n        // You can add more extensions here ...\n    ];\n\n    //If you want to use extensions, here is an example as its recommended to use extensions to build your application.\n    $creator-\u003eloadExtensions($extensions, ['config' =\u003e '%project_dir%/config']);\n\n    // You can set custom pages for caught exceptions, using default event dispatcher, or your custom event dispatcher.\n    $creator-\u003edefinition('events.dispatcher')-\u003ebind('addListener', [Flange\\Events::EXCEPTION, wrap(ErrorListener::class), -8]);\n}, $config);\n\n$app-\u003erun(); // Boot the application.\n\n```\n\nHere's an example of a custom error you can use for your application.\n\n```php\nuse Biurad\\Http\\Response\\HtmlResponse;\nuse Flange\\Event\\ExceptionEvent;\n\nclass ErrorListener\n{\n    public function __invoke(ExceptionEvent $event): void\n    {\n        // If extensions were loaded, the %project_dir% will exist, else replace will absolute path\n        $errorsPath = $event-\u003egetApplication()-\u003eparameter('%project_dir%/errors/');\n\n        $code = $event-\u003egetThrowable()-\u003egetCode();\n        $templates = [\n            $errorsPath . \\substr($code, 0, 2) . 'x.html.php', // 40x.html.php format ...\n            $errorsPath . \\substr($code, 0, 1) . 'xx.html.php', // 4xx.html.php format ...\n            $errorsPath . $code . '.html.php', // 404.html.php format ...\n            $errorsPath . 'default.html.php',\n        ];\n\n        // Tries to load a template file from a list of error templates.\n        foreach ($template as $template) {\n            if (\\file_exists($template)) {\n                $event-\u003esetResponse(\n                    (static function () use ($template, $code) {\n                        \\ob_start();\n                        include __DIR__ . $template;\n\n                        return new HtmlResponse(\\ob_get_clean(), (int) $code);\n                    })()\n                );\n            }\n        }\n    }\n}\n```\n\nImportant to note that, using [PSR-15][5] middlewares stack uses the [PHP][1] SPL Queue class with the following algorithm, LAST \u003c- FIRST : FIRST -\u003e LAST. Loading extensions and events listeners by default uses the priority stacking algorithm (which means the higher the priority, the earlier an extension or event listener will be triggered in the chain) which defaults to 0.\n\n## 📓 Documentation\n\nIn-depth documentation on how to use this library, kindly check out the [documentation][11] for this library. It is also recommended to browse through unit tests in the [tests](./tests/) directory.\n\n## 🙌 Sponsors\n\nIf this library made it into your project, or you interested in supporting us, please consider [donating][12] to support future development.\n\n## 👥 Credits \u0026 Acknowledgements\n\n- [Divine Niiquaye Ibok][@divineniiquaye] is the author this library.\n- [All Contributors][13] who contributed to this project.\n\n## 📄 License\n\nFlange is completely free and released under the [BSD 3 License](LICENSE).\n\n[1]: https://php.net\n[2]: http://www.php-fig.org/psr/psr-7/\n[3]: http://www.php-fig.org/psr/psr-11/\n[4]: http://www.php-fig.org/psr/psr-14/\n[5]: http://www.php-fig.org/psr/psr-15/\n[6]: https://getcomposer.org\n[7]: https://github.com/divineniiquaye/flight-routing\n[8]: https://github.com/biurad/php-di\n[9]: https://github.com/symfony\n[10]: https://github.com/biurad\n[11]: https://divinenii.com/courses/flange/\n[12]: https://biurad.com/sponser\n[13]: https://github.com/biurad/flange/contributors\n[@divineniiquaye]: https://github.com/divineniiquaye\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiurad%2Fflange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiurad%2Fflange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiurad%2Fflange/lists"}