(REQUIRES PHP >= 7.0)
Use this for any Silex 2 project, this package comes with:
- Propel 2 (use
./pcommand) - Twig
- Swiftmailer
- Translation provider
- Security provider (configured users from database)
- Forms provider (with CSRF protection)
- Console provider (with some helpful tools)
- Some small examples
- (optionally) Bootstrap 3 with Sass
- (optionally) Font-awesome
I'm using this as start-base for small to medium custom applications, to hold onto some semantics between my projects and to not have to configure everything from scratch.
If you have experience with Symfony framework or Silex itself and you love Propel ORM like me, then you probably will find it useful for building some webapps without all the pain of configuring services, preparing stuff, etc.
- Download latest release and unpack it in your project dir (get version
bootstrap-faif you want Bootstrap & Font-awesome) - Run
composer install(if you don't have composer go get it)
- Configure
propel.yml.distwith your database credentials - Copy/rename it to
propel.yml - Run
./p config:convert
- Edit
propel/Config/schema.xmlto your database model - Run
./p model:buildto generate classes inpropeldir - Run
./p sql:buildto generate SQL ingenerated-sqldir - Check if generated SQL is ok
- WARNING by default Propel is generating DROP on every table it's going to create, so if you have any existing tables CHECK THE GENERATED SQL!
- Run
./p sql:insertto create tables in DB
- Run
./p database:reverseto create XML file ingenerated-reversed-databasedir - Check generated XML schema, add behaviors etc.
- Copy
my_usertable from existing example schema inpropel/Config/schema.xmlto your newly generated schema (if you don't havemy_usertable in your database add it by following steps of Option 1, or manually) - Move it to
propel/Config/schema.xml - Run
./p model:buildto generate classes inpropeldir
Remove all generated* dirs after using Propel commands, as they are not required
-
Configure
config.rbto your needs if you are using SASS -
Add your Twig extensions in
src/library/Twig.php(some extensions are already built-in) -
Set your localisation settings in
src/library/Services.php
- Change default language in
locale_fallback - Add your xliff translation files if required (example Polish translation provided, create other similar to it)
- All language files are located in
src/translation/
- By default whole path
/adminis secured only for users with ROLE_ADMIN - You can set the firewall as you wish in
src/library/Services.php - Security is configured to use
UserProvidermodel that provides users from tablemy_userwith use of Propel. If you want to use different user table or make other changes - edit it insrc/library/UserProvider.php - You can create/modify new users with encoded passwords using command
manage:user(run./bin/console help manage:userfor more info)
(this command works only with default my_user table!)
- Create structure of files in
srcdir as you require with this guidance:
- Put controllers in
src/controllerand views insrc/view/ControllerName/ - It's recommended to create directories for views like for
frontendController.phpit could besrc/view/Frontend/myView.html.twig
- Add your controllers in
web/index.php - You can enable/disable debug mode in
web/index.php(enabled as default)