icehawk / icehawk
Lightweight PHP routing framework, respecting CQRS
Installs: 28 474
Dependents: 1
Suggesters: 0
Security: 0
Stars: 67
Watchers: 9
Forks: 5
Open Issues: 1
Requires
- php: >=8.1
- ext-fileinfo: *
- psr/container: ^2.0
- psr/http-message: ~1.0
- psr/http-server-handler: ~1.0
- psr/http-server-middleware: ~1.0
Requires (Dev)
- ext-xdebug: *
- roave/security-advisories: dev-latest
- dev-master
- v3.0.0-beta2
- v3.0.0-beta1
- v3.0.0-alpha
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-rc5
- v2.0.0-rc4
- v2.0.0-rc3
- v2.0.0-rc2
- v2.0.0-rc1
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.3.0-rc4
- v1.3.0-rc3
- v1.3.0-rc2
- v1.3.0-rc1
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- dev-3.x-dev
- dev-development
- dev-issue/enable-phpstan
- dev-issue/27
- dev-issue/28
- dev-issue/16
- dev-issue/17
- dev-issue/15
- dev-issue/22
- dev-v2.0-dev
- dev-v2.0-stable
- dev-issue/20
- dev-issue/1-request-default-values
- dev-issue/add-copyright-strict-types
- dev-refactoring/shorten-request-getters
- dev-feature/setup-environment
- dev-release/going-public
This package is auto-updated.
Last update: 2024-04-08 16:23:08 UTC
README
Lightweight PHP routing framework, respecting CQRS.
Requirements
- PHP >= 7.0
- fileinfo extension for handling uploaded files correctly
For development only:
- xdebug extension for running the tests
Installation
composer require icehawk/icehawk:^2.1
or add to your composer.json
:
{ "require": { "icehawk/icehawk": "^2.1" } }
Documentation
A full documentation can be found on our website: icehawk.github.io
Quickstart (installer)
We provide an installer package that creates a new IceHawk project for you. Simply run:
composer create-project -n icehawk/installer /path/to/new-project
Answer the questions of the interactive installer and you're good to go.
» Watch our short video and see how it works: Install IceHawk framework in less than 2 minutes
Quickstart (manual)
Step 0 - Create a basic composer.json
{ "require": { "icehawk/icehawk": "^2.1" }, "autoload": { "psr-4": { "YourVendor\\YourProject\\": "./" } } }
Then run:
composer update
Step 1 - Create a request handler
<?php declare(strict_types = 1); namespace YourVendor\YourProject; use IceHawk\IceHawk\Interfaces\HandlesGetRequest; use IceHawk\IceHawk\Interfaces\ProvidesReadRequestData; final class SayHelloRequestHandler implements HandlesGetRequest { public function handle( ProvidesReadRequestData $request ) { echo "Hello World!"; } }
— SayHelloRequestHandler.php
Step 2 - Create a basic config
All you need is at least one read or write route.
<?php declare(strict_types = 1); namespace YourVendor\YourProject; use IceHawk\IceHawk\Routing\ReadRoute; use IceHawk\IceHawk\Routing\Patterns\Literal; final class IceHawkConfig extends \IceHawk\IceHawk\Defaults\IceHawkConfig { public function getReadRoutes() { return [ new ReadRoute( new Literal('/'), new SayHelloRequestHandler() ), ]; } }
— IceHawkConfig.php
Step 3 - Create a bootstrap script
<?php declare(strict_types = 1); namespace YourVendor\YourProject; use IceHawk\IceHawk\IceHawk; use IceHawk\IceHawk\Defaults\IceHawkDelegate; require('vendor/autoload.php'); $iceHawk = new IceHawk(new IceHawkConfig(), new IceHawkDelegate()); $iceHawk->init(); $iceHawk->handleRequest();
— index.php
Step 4 - Say hello
Go to your project folder an run:
php -S 127.0.0.1:8088
Go to your browser an visit: http://127.0.0.1:8088/
Hello World!
Visit our website for the full documentation.
Contributing
Contributions are welcome! Please see our contribution guide.