Skip to content

Commit bf742b2

Browse files
authored
Updated readme
1 parent de90cac commit bf742b2

File tree

1 file changed

+52
-46
lines changed

1 file changed

+52
-46
lines changed

README.md

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
1-
# BitFrame PHP Microframework
2-
31
[![codecov](https://codecov.io/gh/designcise/bitframe/branch/master/graph/badge.svg?token=7V77L5P3AX)](https://codecov.io/gh/designcise/bitframe)
42
[![Build Status](https://travis-ci.com/designcise/bitframe.svg?branch=master)](https://travis-ci.com/designcise/bitframe)
53

6-
## At-a-glance
7-
8-
* Highly customizable PSR-15 and PSR-7 compatible middleware-based microframework for PHP;
9-
* Simple PSR-11 based dependency injection container;
10-
* Simple to learn, use and implement;
11-
* Follows the [PSR standards](http://www.php-fig.org/) and integrates the best of existing opensource frameworks wherever possible.
4+
# BitFrame PHP Microframework
125

13-
## Why use BitFrame?
6+
A highly customizable PSR-15 / PSR-7 compatible middleware-based microframework for PHP that comes bundled with a simple PSR-11 based DI container for sharing services and data across the application. It is:
147

15-
BitFrame's approach of making the middleware dispatcher the core component of the framework encourages the developer to use middleware-based services that plug right-in with ease. This allows for greater flexibility especially in terms of debugging, replacements and updating. While this design pattern may not suit the needs of all projects, it certainly has its advantages for long-term and strategic ones because as they grow in complexity the underlying framework helps keep things well-organized, easy-to-manage and very simple.
8+
1. Easy-to-learn and intuitive;
9+
2. Standards-based;
10+
4. Simple by design;
11+
5. Free of unnecessary bloat;
12+
6. Non-intrusive;
13+
7. Customizable, modular and easy-to-scale.
1614

17-
At the core of our development, we've tried very hard to abide by some simple rules that we've mostly found missing in other microframeworks:
15+
## How to Get Started?
1816

19-
1. **Easy-to-learn:** Be well-documented and intuitive;
20-
1. **Non-intrusive:** Facilitate the developer and not be a nuisance;
21-
1. **Simple by design:** Encourage flow of development to be simple and easy to read;
22-
1. **Customizable:** Promote modularity and high customizability;
23-
1. **Fat-free:** Be free of unnecessary bloat;
24-
1. **Standards-based:** Be standards-based wherever possible.
17+
You can get started in a few simple steps:
2518

26-
## Installation
19+
1. Setup your environment;
20+
2. Install `composer` dependencies;
21+
3. Create your first "Hello World" app.
2722

28-
Install BitFrame and its required dependencies using composer:
23+
Also, please note the following prerequisites:
2924

30-
```
31-
$ composer require "designcise/bitframe"
32-
```
25+
### Prerequisites
3326

34-
Please note that BitFrame v3+ requires PHP 8.0.0 or newer.
27+
1. PHP 8.0+;
28+
2. Server with URL Rewriting (such as Apache, Nginx, etc.).
3529

36-
## Quickstart
30+
### 1. Setup Your Environment
3731

38-
Get started quickly by using the boilerplate code at https://github.com/designcise/bitframe-boilerplate.
32+
You can refer to the following minimal Apache and Nginx configurations to get started:
3933

40-
### Apache
34+
#### Apache
4135

42-
After you have installed the required dependencies specific to your project, create an `.htaccess` file with at least the following code:
36+
Create an `.htaccess` file with at least the following code:
4337

4438
```apacheconfig
4539
RewriteEngine On
@@ -48,11 +42,11 @@ RewriteCond %{REQUEST_FILENAME} !-d
4842
RewriteRule ^ index.php [QSA,L]
4943
```
5044

51-
This sets the directive in apache to redirect all Http Requests to `index.php` in which we can write our application code.
45+
This sets the directive in Apache to redirect all Http requests to a front controller `index.php` file in which you can write your main application code.
5246

53-
### Nginx
47+
#### Nginx
5448

55-
A configuration like the following in nginx will help you set the directive to rewrite path to our application front controller (i.e. `index.php`):
49+
A configuration like the following in Nginx will help you set the directive to rewrite path to your application front controller (i.e. `index.php`):
5650

5751
```
5852
server {
@@ -82,9 +76,21 @@ server {
8276

8377
Remember to make changes according to your project setup. For example, ensure that `listen`, `root`, `fastcgi_pass`, `*_log`, etc. are setup correctly according to your project.
8478

85-
### Example
79+
### 2. Install Composer Dependencies
8680

87-
For a full application example, please [check out the boilerplate](https://github.com/designcise/bitframe-boilerplate).
81+
You can use `composer require` like so:
82+
83+
```
84+
$ composer require "designcise/bitframe":^3.5
85+
```
86+
87+
Or, alternatively, you can add the package dependency in your `composer.json` file.
88+
89+
Please note that you must include a PSR-17 factory in your composer dependencies. [nyholm/psr7](https://github.com/Nyholm/psr7/blob/master/src/Factory/Psr17Factory.php) and [guzzle/psr7](https://github.com/guzzle/psr7/blob/master/src/HttpFactory.php) are good examples of these — if you include either of these, they're automatically picked up by BitFrame. For any other PSR-17 factory implementation, you can add it add via `\BitFrame\Factory\HttpFactory::addFactory()` method before you instantiate `\BitFrame\App`.
90+
91+
### 3. Create Your First "Hello World" App
92+
93+
If you have ever used a middleware based framework, you will feel at ease. A "Hello World" app would look something like the following:
8894

8995
```php
9096
<?php
@@ -96,6 +102,7 @@ use Psr\Http\Server\RequestHandlerInterface;
96102
use BitFrame\App;
97103
use BitFrame\Emitter\SapiEmitter;
98104

105+
// 1. Instantiate the App
99106
$app = new App();
100107

101108
$middleware = function (ServerRequestInterface $request, RequestHandlerInterface $handler) {
@@ -104,31 +111,34 @@ $middleware = function (ServerRequestInterface $request, RequestHandlerInterface
104111
return $response;
105112
};
106113

114+
// 2. Add middleware
107115
$app->use([
108116
SapiEmitter::class,
109117
$middleware,
110118
]);
111119

120+
// 3. Run the application
112121
$app->run();
113122
```
114123

115-
From the code above you can see that we're using two middlewares:
124+
From the code above you can see that the application uses two middlewares:
116125

117-
1. A PSR-15 middleware `\BitFrame\Emitter\SapiEmitter` that allows us to emit the HTTP Response to the requesting user-agent (such as a web browser);
118-
1. A closure middleware used to write `Hello World!` to the HTTP Response.
126+
1. A PSR-15 middleware `\BitFrame\Emitter\SapiEmitter` (that comes bundled with BitFrame package) which allows to emit the HTTP Response to the requesting user-agent (such as a web browser);
127+
2. A closure middleware used to write `Hello World!` to the HTTP response stream.
119128

120-
This is of course a very basic example. You could extend the functionality by using additional middleware such as a [router](https://github.com/designcise/bitframe-fastroute), error handler, etc.
129+
This is of course a very basic example. In a real-world application, the setup would be much more complex than this. For example, you could extend the functionality by using an additional PSR-15 middleware such as a [router](https://github.com/designcise/bitframe-fastroute), [error handler](https://github.com/designcise/bitframe-whoops), etc. For suggestions on how to go about designing your application (and to get started quickly), have a look at the [simple dockerized boilerplate example](https://github.com/designcise/bitframe-boilerplate).
121130

122131
## Tests
123132

124133
To run the tests you can use the following commands:
125134

126-
| Command | Type |
127-
| ---------------- |:---------------:|
128-
| `composer test` | PHPUnit tests |
129-
| `composer style` | CodeSniffer |
130-
| `composer md` | MessDetector |
131-
| `composer check` | PHPStan |
135+
| Command | Type |
136+
| ------------------- |:----------------:|
137+
| `composer test` | PHPUnit tests |
138+
| `composer style` | CodeSniffer |
139+
| `composer style-fix`| CodeSniffer Fixer|
140+
| `composer md` | MessDetector |
141+
| `composer check` | PHPStan |
132142

133143
### Contributing
134144

@@ -137,10 +147,6 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
137147
* File issues at https://github.com/designcise/bitframe/issues
138148
* Issue patches to https://github.com/designcise/bitframe/pulls
139149

140-
### Documentation
141-
142-
Complete documentation for v3 will be released soon.
143-
144150
### License
145151

146152
Please see [License File](LICENSE.md) for licensing information.

0 commit comments

Comments
 (0)