|
| 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. |
0 commit comments