Web Application Starter Kit
A simple web application boilerplate for min or mid scale applications. Included user system (login, logout, register, reset password, profile, edit profile and change password), users, roles, simple statistics, settings and more.
- PHP > 5.3.9
- Composer
- Bower
- PHP Coding Standards Fixer (optional)
- Navigate yor your web directory:
cd /var/www
- Create a new project:
composer create-project bobalazek/web-application-starter-kit myapp --no-scripts
- Navigate inside the application
cd myapp
- Configure database (and maybe other stuff if you want): app/configs/global.php or app/configs/global-local.php.example (in case you will deploy it and need a different local configuration. Just rename the global-local.php.example to global-local.php and set your own configuration)
- Run the following commands:
composer install
bin/console orm:schema-tool:update --force
(to install the database schema)bower update
(to install the front-end dependencies - you will need to install Bower first - if you haven't already)bin/console application:database:hydrate-data
(to hydrate some data)
- You are done! Start developing!
- We use the Doctrine database
- Navigate to your project directory:
cd /var/www/myapp
- Check the entities:
bin/console orm:info
(optional) - Update the schema:
bin/console orm:schema-tool:update --force
- Database updated!
You should replace the name for your actual application inside the following files:
- README.md
- bower.json
- composer.json
- phpunit.xml
- app/configs/global.php
With the bin/console application:database:hydrate-data
command, you will, per default hydrate 2 users (which you can change inside the app/fixtures/users.php
file):
- Admin User (with admin permissions)
- Username:
admin
oradmin@myapp.com
- Password:
test
- Username:
- Test User (with the default user permissions)
- Username:
test
ortest@myapp.com
- Password:
test
- Username:
bin/console application:environment:prepare
- Will create the global-local.php and development-local.php files (if they do not exist)bin/console application:database:hydrate-data [-r|--remove-existing-data]
- Will hydrate the tables with some basic data, like: 2 users and 6 roles (the--remove-existing-data
flag will truncate all tables before re-hydrating them)bin/console application:storage:prepare
- Will prepare all the storage (var/) folders, like: cache, logs, sessions, etc.bin/console application:translations:prepare
- Prepares all the untranslated string into a separate (app/locales/{locale}_untranslated.yml) file. Accepts an locale argument (defaults to 'en_US' - usage:bin/console application:translations:prepare --locale de_DE
orbin/console application:translations:prepare -l de_DE
)
php-cs-fixer fix .
- if you want your code fixed before each commit. You will need to install PHP Coding Standards Fixer
In case you want to create a new component / module in this system, do the following (in this case, the posts inside the members area):
- Create a new Controller Provider (like src/Application/ControllerProvider/MembersArea/PostsControllerProvider.php - plural)
- Bind with the following routes:
- Overview / list:
- Route name: members-area.posts
- Route pattern / url: (blank)
- Route controller method: PostsController::indexAction
- New:
- Route name: members-area.posts.new
- Route pattern / url: /new
- Route controller method: PostsController::newAction
- Detail:
- Route name:
members-area.posts.detail
- Route pattern / url:
/{id}
- Route controller method:
PostsController::detailAction
- Route name:
- Edit:
- Route name: members-area.posts.edit
- Route pattern / url: /{id}/edit
- Route controller method: PostsController::editAction
- Remove:
- Route name: members-area.posts.remove
- Route pattern / url: /{id}/remove
- Route controller method: PostsController::removeAction
- Overview / list:
- Bind with the following routes:
- Create a new Controller (src/Application/Controller/MembersArea/PostsController.php - plural)
- With the following methods:
- PostsController::indexAction - for the list template
- PostsController::newAction - for the new templates
PostsController::detailAction
- for the details template- PostsController::editAction - for the edit template
- PostsController::removeAction - for the remove template
- With the following methods:
- Mount the routes of the Controller Provider to the routes (app/core/routes.php)
- Create a new Entity (src/Application/Entity/PostEntity.php - singular)
- Create a new Repository (src/Application/Repository/PostRepository.php - singular)
- Create a new Form Type (src/Application/Form/Type/PostType.php - singular)
- Create templates:
- app/templates/contents/members-area/posts/ (plural)
- index.html.twig (normally just extends the list.html.twig)
- list.html.twig
detail.html.twig
- new.html.twig
- edit.html.twig
- remove.html.twig
- _form.html.twig (just include that inside the edit and new template, so you don't need to write the same form twice - if it's more complex)
- app/templates/contents/members-area/posts/ (plural)
- app/
- configs/ => All basic config stuff (+ validation)
- core/ => The core files such as providers, routes, middlewares, common functions and definitions
- fixtures/ => Used when hydrating the database
- locales/ => Translations & co.
- templates/ => All twig templates
- bin/
- console
- src/
- Application/
- Command/
- Controller/
- ControllerProvider/
- Doctrine/ => Some Doctrine fixes for Silex
- Entity/ => All entities / models
- Form/
- Provider/
- Repository/
- Tool/
- Twig/
- Application/
- web/
- assets/
- images/
- javascripts/
- uploads/ => Used for uploads
- vendor/ => Bower dependencies
- index.php
- assets/
Web Application Starter Kit is licensed under the MIT license.