Skip to content

Commit 46025a2

Browse files
committed
Initial commit
0 parents  commit 46025a2

21 files changed

+421
-0
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.git
2+
.gitignore
3+
LICENSE
4+
README.md
5+
CHANGELOG.md

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vendor
2+
.idea
3+
.DS_Store
4+
*.cache
5+
composer.lock

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# How to Contribute
2+
3+
## Pull Requests
4+
5+
1. Fork the BitFrame Framework repository;
6+
1. Create a new branch for each feature or improvement;
7+
1. Send a pull request from each feature branch against the version branch for which your fix is intended.
8+
9+
It is very important to separate new features or improvements into separate feature branches, and to send a pull request for each branch. This allows each feature or improvement to be reviewed and merged individually.
10+
11+
## Style Guide
12+
13+
All pull requests must adhere to the PSR-12 standard.
14+
15+
## Unit Testing
16+
17+
All pull requests must be accompanied by passing unit tests and complete code coverage. The BitFrame Framework uses [PHPUnit](https://phpunit.de/) for testing.

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM composer:latest AS composer
2+
3+
FROM php:7.4.0-fpm AS base
4+
COPY --from=composer /usr/bin/composer /usr/bin/composer
5+
6+
WORKDIR /var/www/html
7+
8+
COPY www .
9+
10+
# ---- Dependencies ----
11+
FROM base AS dependencies
12+
13+
RUN composer install \
14+
--no-suggest \
15+
--ignore-platform-reqs \
16+
--no-interaction \
17+
--no-plugins \
18+
--no-scripts \
19+
--optimize-autoloader \
20+
--prefer-dist
21+
22+
# ---- Release ----
23+
FROM base AS release
24+
25+
COPY --from=dependencies /var/www/html/vendor/ ./vendor
26+
27+
COPY . .

LICENSE.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# License
2+
3+
### Copyright (c) 2017-2020 Daniyal Hamid (https://designcise.com)
4+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
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.
10+
11+
### Third-party software used in BitFrame Microframework
12+
13+
Portions of the BitFrame microframework either build-upon or take inspiration from the work done by:
14+
15+
- **PHP Framework Interoperability Group**
16+
* Credit For: Interoperability Interfaces
17+
* Copyright (c) 2012 PHP Framework Interoperability Group
18+
* MIT License
19+
20+
- **Zend Technologies USA Inc.**
21+
* Credit For: Emitter, Renderer & Http Factory Functions
22+
* 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 <[email protected]>
33+
* MIT License
34+
35+
- **Phil Bennett**
36+
* Credit For: Router
37+
* Copyright (c) 2017 Phil Bennett <[email protected]>
38+
* MIT License
39+
40+
- **Slim Framework**
41+
* Credit For: Http Decorators
42+
* Copyright (c) 2015 Slim Framework
43+
* MIT License

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# BitFrame PHP Microframework Boilerplate
2+
3+
## Installation
4+
5+
Simply clone the repo and start building your projects.
6+
7+
### Prerequisites:
8+
9+
- PHP 7.4.0+
10+
- Nginx
11+
- Docker Engine 1.13.0+
12+
13+
## Directory Structure
14+
15+
The following directory structure is recommended for development:
16+
17+
```
18+
root (www)
19+
├── client
20+
│ ├── ...
21+
├── public
22+
│ ├── static
23+
│ └── index.php
24+
├── server
25+
│ ├── app
26+
│ ├── config
27+
│ ├── helper
28+
│ └── test
29+
├── composer.json
30+
└── ...
31+
```
32+
33+
| Folder | Description |
34+
| ------------- |:-------------:|
35+
| client | Frontend app code. |
36+
| public | Publicly accessible client-facing directory. |
37+
| server | Backend app code. |
38+
39+
## Quickstart
40+
41+
### Getting Started:
42+
43+
Navigate to the `bitframe-boilerplate` project directory and run:
44+
45+
```
46+
docker-compose up
47+
```
48+
49+
Then, point your browser to access the example route `/hello/test`. For example, using default nginx config in the docker container, the complete url might look something like this:
50+
51+
```
52+
http://localhost:8000/hello/test
53+
```
54+
55+
But this may vary depending on your server configurations.
56+
57+
### Application Design Overview:
58+
59+
Following would get you up to speed about the application design:
60+
61+
- The main app code resides in the front-controller file at `public/index.php`.
62+
- The main app code is wrapped in a self-calling anonymous function to keep the global namespace clean.
63+
- The default controller (`BitFrame\Controller`) can be used as a service container, or you can inject your own as the first argument to `BitFrame\App`.
64+
- The handy `import` function (`YourProject\Helper\import`) is used to import different parts of the application. This helps reduce visual clutter and keep things maintainable.
65+
- The important directory paths are all defined as constants in `YourProject\App\Server`.
66+
- The router is programmed to automatically pick-up the action part of the url path and match it against a method inside the controller with the same name, suffixed with `Action`.
67+
- The `BitFrame\App::use()` method can be used to add middlewares. We use two middlewares in the example, one to emit the response and one for the router.
68+
69+
### Customizing:
70+
71+
You may begin by customizing `root > server > composer.json`:
72+
73+
1. Start by customizing the name, author, version, etc. for your project. If you change the package name, make sure you update it in `root > composer.json` as well under "required" dependencies.
74+
1. Add appropriate namespace to your app code by replacing `YourProject` with something else. Accordingly, please update namespaces throughout the project. A simply find / replace operation would help.
75+
1. Run `composer dumpautoload` and/or `composer update` to `root > composer.json` to see the changes.
76+
77+
Next you can add more middleware, routes, controllers, services, etc. and start building your project. If you wish to change the directory structure, please update the constants in `YourProject\App\Server`.
78+
79+
## Contributing
80+
81+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
82+
83+
* File issues at https://github.com/designcise/bitframe/issues
84+
* Issue patches to https://github.com/designcise/bitframe/pulls
85+
86+
## Documentation
87+
88+
Complete documentation for v2.0 will be available soon on https://bitframephp.com.
89+
90+
## License
91+
92+
Please see [License File](LICENSE.md) for licensing information.

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
web:
4+
image: nginx:latest
5+
container_name: bitframex
6+
ports:
7+
- "8000:80"
8+
depends_on:
9+
- app
10+
volumes:
11+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
12+
app:
13+
container_name: bitframephp
14+
build: .
15+
volumes:
16+
- ./www:/var/www/html

nginx.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
server {
2+
listen 80;
3+
server_name 127.0.0.1;
4+
5+
root /var/www/html/public;
6+
index index.php;
7+
8+
location / {
9+
try_files $uri $uri/ /index.php$is_args$args;
10+
}
11+
12+
location ~ \.php$ {
13+
fastcgi_split_path_info ^(.+\.php)(/.+)$;
14+
fastcgi_pass app:9000;
15+
fastcgi_index index.php;
16+
include fastcgi_params;
17+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
18+
fastcgi_param PATH_INFO $fastcgi_path_info;
19+
}
20+
21+
access_log /var/log/nginx/access.log;
22+
error_log /var/log/nginx/error.log;
23+
}

www/composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"repositories": [
3+
{
4+
"type": "path",
5+
"url": "server"
6+
}
7+
],
8+
"require": {
9+
"your-project/server": "*",
10+
"designcise/bitframe": "2.x-dev",
11+
"designcise/bitframe-fastroute": "2.x-dev",
12+
13+
"nyholm/psr7": "^1.2",
14+
"middlewares/trailing-slash": "^1.0"
15+
},
16+
"require-dev": {
17+
"roave/security-advisories": "dev-master",
18+
"phpunit/phpunit": "^8.5",
19+
"squizlabs/php_codesniffer": "3.*",
20+
"phpmd/phpmd": "@stable"
21+
},
22+
"scripts": {
23+
"style": "vendor/bin/phpcs --standard=PSR12 server",
24+
"test": "vendor/bin/phpunit --configuration phpunit.xml --testsuite unit"
25+
}
26+
}

0 commit comments

Comments
 (0)