You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Portions of the BitFrame framework incorporates the work by (as provided under the New BSD license):
5
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
6
11
-
* Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
7
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
8
13
-
All other copyright for the BitFrame framework are held by (as provided under the MIT lincense):
9
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
### Third-party software used in BitFrame Microframework
16
12
17
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
+
Portions of the BitFrame microframework either build-upon or take inspiration from the work done by:
18
14
19
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
+
-**PHP Framework Interoperability Group**
16
+
* Credit For: Interoperability Interfaces
17
+
* Copyright (c) 2012 PHP Framework Interoperability Group
* Copyright (c) 2015-2017 Zend Technologies USA Inc. (http://www.zend.com)
23
+
* New BSD license
24
+
25
+
-**Oscar Otero Marzoa**
26
+
* Credit For: HttpFactory
27
+
* Copyright (c) 2018 Oscar Otero Marzoa (https://oscarotero.com)
28
+
* MIT License
29
+
30
+
-**Guzzle Http**
31
+
* Credit For: Http Factory Functions
32
+
* Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling<mtdowling@gmail.com>
33
+
* MIT License
34
+
35
+
-**Phil Bennett**
36
+
* Credit For: Router
37
+
* Copyright (c) 2017 Phil Bennett <philipobenito@gmail.com>
38
+
* MIT License
20
39
21
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Highly customizable PSR-15 and PSR-7 compatible middleware-based microframework for PHP;
9
+
* Simple PSR-11 based dependency injection container;
4
10
* Simple to learn, use and implement;
5
11
* Follows the [PSR standards](http://www.php-fig.org/) and integrates the best of existing opensource frameworks wherever possible.
6
12
7
-
###Why use BitFrame?
13
+
## Why use BitFrame?
8
14
9
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.
10
16
11
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:
12
18
13
-
1. Be well-documented and intuitive;
14
-
1. Facilitate the developer and be nonintrusive;
15
-
1.Be free of unnecessary bloat;
16
-
1. Promote modularity to allow any component of the framework to be easily replaced;
17
-
1.Provide the flexibility of using existing PSR-15 / PSR-7 middlewares that plug right in easily;
18
-
1.Provide the ability to share variables and application data seamlessly across all the middlewares.
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.
19
25
20
-
###Installation
26
+
## Installation
21
27
22
28
Install BitFrame and its required dependencies using composer:
23
29
24
30
```
25
-
$ composer require designcise/bitframe
31
+
$ composer require "designcise/bitframe"
26
32
```
27
33
28
-
Please note that BitFrame requires PHP 7.1.0 or newer.
34
+
Please note that BitFrame v2+ requires PHP 7.4.0 or newer.
35
+
36
+
## Quickstart
37
+
38
+
Get started quickly by using the boilerplate code at https://github.com/designcise/bitframe-boilerplate.
29
39
30
-
### Quickstart
40
+
### Apache
31
41
32
42
After you have installed the required dependencies specific to your project, create an `.htaccess` file with at least the following code:
33
43
34
-
```
44
+
```apacheconfig
35
45
RewriteEngine On
36
46
RewriteCond %{REQUEST_FILENAME} !-f
37
47
RewriteCond %{REQUEST_FILENAME} !-d
38
48
RewriteRule ^ index.php [QSA,L]
39
49
```
40
50
41
-
This sets the directive in apache to redirect all Http Requests to `index.php` in which we can write our application code. For example:
51
+
This sets the directive in apache to redirect all Http Requests to `index.php` in which we can write our application code.
52
+
53
+
### Nginx
42
54
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`):
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.
84
+
85
+
### Example
86
+
87
+
For a full application example, please [check out the boilerplate](https://github.com/designcise/bitframe-boilerplate).
$middleware = function (ServerRequestInterface $request, RequestHandlerInterface $handler) {
102
+
$response = $handler->handle($request);
103
+
$response->getBody()->write('Hello World!');
104
+
return $response;
105
+
};
106
+
107
+
$app->use([
108
+
SapiEmitter::class,
109
+
$middleware,
57
110
]);
58
111
59
112
$app->run();
60
113
```
61
114
62
115
From the code above you can see that we're using two middlewares:
63
116
64
-
1. A PSR-15 based wrapper of [Zend Diactoros](https://github.com/zendframework/zend-diactoros) that allows us to emit the HTTP Response to the requesting user-agent (such as a web browser);
65
-
1. A closure used to write `Hello World!` to the HTTP Response.
66
-
67
-
Similar to the `\BitFrame\Message\DiactorosResponseEmitter` middleware package [we've developed some essential PSR-15 packages](https://www.bitframephp.com/doc/getting-started/install#how-to-install-project-dependencies-middlewares) that are typically used in API and web app development. These can be added to BitFrame easily as per your project's need and are in no way a hard dependency.
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.
68
119
69
-
Also note that, apart from these official packages, you can easily use any PSR-15 or PSR-7 based packages, or develop your own.
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/tree/2.x), error handler, etc.
70
121
71
-
Refer to the [official BitFrame documentation](https://www.bitframephp.com/doc/) to learn more.
122
+
## Tests
72
123
73
-
### Tests
124
+
To run the tests you can use the following commands:
74
125
75
-
To execute the test suite, you will need [PHPUnit](https://phpunit.de/).
126
+
| Command | Type |
127
+
| ---------------- |:---------------:|
128
+
|`composer test`| PHPUnit tests |
129
+
|`composer style`| CodeSniffer |
130
+
|`composer md`| MessDetector |
131
+
|`composer check`| PHPStan |
76
132
77
133
### Contributing
78
134
@@ -83,9 +139,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
83
139
84
140
### Documentation
85
141
86
-
Documentation is available at:
87
-
88
-
*https://www.bitframephp.com/doc/
142
+
Complete documentation for v2.0 will be released soon.
0 commit comments