(REQUIRES PHP >= 7.0)
Use this for any Silex 2 project, this package comes with:
- Propel 2 (use
./p
command) - 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-fa
if you want Bootstrap & Font-awesome) - Run
composer install
(if you don't have composer go get it)
- Configure
propel.yml.dist
with your database credentials - Copy/rename it to
propel.yml
- Run
./p config:convert
- Edit
propel/Config/schema.xml
to your database model - Run
./p model:build
to generate classes inpropel
dir - Run
./p sql:build
to generate SQL ingenerated-sql
dir - 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:insert
to create tables in DB
- Run
./p database:reverse
to create XML file ingenerated-reversed-database
dir - Check generated XML schema, add behaviors etc.
- Copy
my_user
table from existing example schema inpropel/Config/schema.xml
to your newly generated schema (if you don't havemy_user
table in your database add it by following steps of Option 1, or manually) - Move it to
propel/Config/schema.xml
- Run
./p model:build
to generate classes inpropel
dir
Remove all generated*
dirs after using Propel commands, as they are not required
-
Configure
config.rb
to 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
/admin
is 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
UserProvider
model that provides users from tablemy_user
with 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:user
for more info)
(this command works only with default my_user
table!)
- Create structure of files in
src
dir as you require with this guidance:
- Put controllers in
src/controller
and views insrc/view/ControllerName/
- It's recommended to create directories for views like for
frontendController.php
it 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)