Skip to content

Commit b109663

Browse files
author
Marco Bunge
committed
Fix typo
1 parent 969e67b commit b109663

1 file changed

Lines changed: 29 additions & 68 deletions

File tree

README.md

Lines changed: 29 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ Hawkbit is a high customizable, middleware aware, event driven,
1414

1515
Hawkbit uses latest versions of [League\Route](https://github.com/thephpleague/route) for routing,
1616
[League\Container](https://github.com/thephpleague/container) for dependency injection,
17-
[League\Event](https://github.com/thephpleague/event) for event dispatching,
18-
[League\Tactican](https://github.com/thephpleague/tactican) as middleware runner and
17+
[League\Event](https://github.com/thephpleague/event) for event dispatching,
1918
[Zend Config](https://docs.zendframework.com/zend-config/) for configuration.
2019

21-
Hawkbit is an advanced derivate of [Proton](https://github.com/alexbilbie/Proton) and part of () Component collection by Marco Bunge.
20+
Hawkbit is an advanced derivate of [Proton](https://github.com/alexbilbie/Proton) and part of Hawkbit Component collection by Marco Bunge. Hawkbit 1.x is also known as Blast Hawkbit.
2221

2322
## Install
2423

@@ -35,7 +34,7 @@ composer.json
3534
```javascript
3635
{
3736
"require": {
38-
"Hawkbit": "~1.0"
37+
"hawkbit/hawkbit": "~2.0"
3938
}
4039
}
4140
```
@@ -63,13 +62,13 @@ The following versions of PHP are supported by this version.
6362

6463
### Vagrant
6564

66-
Hawkbit use scotch box with additional xdebug support, modified php setup and mailcatcher for development.
65+
Hawkbit uses scotch box with additional xdebug support, modified php setup and mailcatcher for development.
6766

6867
Please read <a href="https://box.scotch.io/" target="_blank">scotch box documentation</a> for more information.
6968

7069
#### Project development
7170

72-
If your project ist depending on `Hawkbit`, you may use the box your project development. You
71+
If your project depends on `Hawkbit`, you may use this box for your project development. You
7372
just need to install your composer dependencies and run following commands within your project
7473
folder.
7574

@@ -133,14 +132,16 @@ See also our example at `/public/index.php`.
133132

134133
## Configuration
135134

136-
Extend configuration of an existing instance
135+
Add additional configuration to application
137136

138137
```php
139138
<?php
140139

141140
//add many values
142141
$app->setConfig([
143-
'database' => 'mysql://root:root@localhost/acmedb',
142+
'database' => [
143+
'default' => 'mysql://root:root@localhost/acmedb',
144+
],
144145
'services' => [
145146
'Acme\Services\ViewProvider',
146147
]
@@ -159,69 +160,27 @@ Access configuration
159160
$app->getConfig();
160161

161162
//get one configuration item
162-
$app->getConfig('database');
163+
$app->getConfig('database'); // returns ['default' => 'mysql://root:root@localhost/acmedb']
164+
165+
//get one configuration item via dotnotation
166+
$app->getConfig('database.default'); // returns 'mysql://root:root@localhost/acmedb'
163167
```
164168

165169
## Middlewares
166170

167171
Hawkbit middlewares allows advanced control of lifecycle execution.
168-
169-
Hawkbit uses `Hawkbit\ApplicationRunnerMiddeware` by default, if no middleware with interface
170-
`Turubine\HttpMiddlewareInterface` exists.
171-
172-
```php
173-
$app->addMiddleware(new Acme\ApplicationRunnerMiddleware);
174-
```
175-
176-
### Using middlewares
177-
178-
#### Automatically register ServiceProviders from Config
179-
180-
Create your configuration
181172

182173
```php
183174
<?php
184-
//config.php
185175

186-
return [
187-
'providers' => [
188-
Acme\ServiceProvider::class
189-
]
190-
];
191-
```
192-
193-
Add configuration to application and add middleware
194-
195-
```php
196-
<?php
197-
198-
$app = new \Hawkbit\Application(include 'config.php');
199-
$app->addMiddleware(new \Hawkbit\Application\ServiceProvidersFromConfigMiddleware());
176+
$app->addMiddleware(new Acme\SomeMiddleware);
200177
```
201178

202-
#### Reuse middleware integration
203-
204-
You are also able to reuse the middleware implementatio in other classes e.g. Controllers.
205-
206-
```php
207-
<?php
208-
209-
use Hawkbit\Application;
210-
211-
class MyController{
212-
213-
public function __construct(Application $application){
214-
// you need to add this to your config or where ever you want
215-
$middlewares = $application->getConfig('middlewares');
216-
$application->handleMiddlewares($this, $middlewares[__CLASS__]);
217-
}
218-
219-
}
220-
```
179+
Hawkbit uses it's own runner `Hawkbit\Application\MiddelwareRunner`
221180

222181
## Routing
223182

224-
Hawkbit is using routing integration of `league/route` and allows access to route collection methods directly.
183+
Hawkbit uses routing integration of `league/route` and allows access to route collection methods directly.
225184

226185
Basic usage with anonymous functions:
227186

@@ -264,7 +223,6 @@ $app->get('/hello/{name}', function ($request, $response, $args) {
264223

265224
```
266225

267-
268226
Basic usage with controllers:
269227

270228
```php
@@ -308,7 +266,7 @@ require __DIR__.'/../vendor/autoload.php';
308266

309267
$app = new Hawkbit\Application();
310268

311-
$app->share('CustomService', new \CustomService);
269+
$app->getContainer()->add('CustomService', new CustomService);
312270
$app->get('/', 'HomeController::index'); // calls index method on HomeController class
313271

314272
$app->run();
@@ -349,8 +307,6 @@ class HomeController
349307
{
350308
//do somehing with service
351309
$service = $this->getService();
352-
353-
$response->getBody()->write();
354310
return $response;
355311
}
356312
}
@@ -365,7 +321,7 @@ Hawkbit add support for route groups.
365321
```php
366322
<?php
367323

368-
$app->group('/admin', function ($route) {
324+
$app->group('/admin', function (\League\Route\RouteGroup $route) {
369325

370326
//access app container (or any other method!)
371327
$app = $this;
@@ -402,13 +358,13 @@ $app->get('/', function ($request, $response) {
402358

403359
$httpKernel = new Hawkbit\Symfony\HttpKernelAdapter($app);
404360

405-
$stack = (new Stack\Builder())
361+
$stack = (new \Stack\Builder())
406362
->push('Some/MiddleWare') // This will execute first
407363
->push('Some/MiddleWare') // This will execute second
408364
->push('Some/MiddleWare'); // This will execute third
409365

410366
$app = $stack->resolve($httpKernel);
411-
Stack\run($httpKernel); // The app will run after all the middlewares have run
367+
\Stack\run($httpKernel); // The app will run after all the middlewares have run
412368
```
413369

414370
### Zend Stratigility
@@ -625,7 +581,12 @@ You can fire custom events using the event emitter directly:
625581
<?php
626582

627583
// addListener
628-
$app->addListener('custom.event', function (\Hawkbit\Application\ApplicationEvent $event, $time) {
584+
$app->addListener('custom.event', function ($event, $time) {
585+
return 'the time is '.$time;
586+
});
587+
588+
// or with class addListener
589+
$app->addListener(Acme\Event::class, function (Acme\Event $event, $time) {
629590
return 'the time is '.$time;
630591
});
631592

@@ -662,7 +623,7 @@ $app['db'] = function () use($app) {
662623
};
663624
```
664625

665-
or by accessing the container directly:
626+
or by container access:
666627

667628
```php
668629
<?php
@@ -740,12 +701,12 @@ Get container
740701
```php
741702
<?php
742703

743-
$app->getContainer($container);
704+
$app->getContainer();
744705
```
745706

746707
## Services
747708

748-
Hawkbit uses dependecy injection container to access it's services. Following integrations can be exchanged.
709+
Hawkbit uses dependency injection container to access services. Following integrations can be exchanged.
749710

750711
### Configurator
751712

0 commit comments

Comments
 (0)