ZffSprout
A minimalist and elegant Skeleton Application for ZF2, yet powerful starter application, see the list of included features., (*1)
Introduction
This is a fork of the official ZendSkeletonApplication. The objective of Sprout is save your time and effort when you are creating a ZF2 Application from scratch., (*2)
Installation using Composer
The easiest way to create a new ZF2 project is to use Composer. If you don't have it already installed, then please install as per the documentation., (*3)
Create your new ZF2 project:, (*4)
composer create-project -n -sdev fagundes/zff-sprout path/to/install
Installation using a tarball with a local Composer
If you don't have composer installed globally then another way to create a new ZF2 project is to download the tarball and install it:, (*5)
-
Download the tarball, extract it and then install the dependencies with a locally installed Composer:, (*6)
cd my/project/dir
curl -#L https://github.com/fagundes/ZffSprout/tarball/master | tar xz --strip-components=1
-
Download composer into your project directory and install the dependencies:, (*7)
curl -s https://getcomposer.org/installer | php
php composer.phar install
If you don't have access to curl, then install Composer into your project as per the documentation., (*8)
Web server setup
PHP CLI server
The simplest way to get started if you are using PHP 5.4 or above is to start the internal PHP cli-server in the root
directory:, (*9)
php -S 0.0.0.0:8080 -t public/ public/index.php
This will start the cli-server on port 8080, and bind it to all network
interfaces., (*10)
Note: The built-in CLI server is for development only., (*11)
Vagrant server
This project supports a basic Vagrant configuration with an inline shell provisioner to run the Skeleton Application in a VirtualBox., (*12)
-
Run vagrant up command, (*13)
vagrant up, (*14)
-
Visit http://localhost:8085 in your browser, (*15)
Look in Vagrantfile for configuration details., (*16)
Apache setup
To setup apache, setup a virtual host to point to the public/ directory of the
project and you should be ready to go! It should look something like below:, (*17)
<VirtualHost *:80>
ServerName zf2-app.localhost
DocumentRoot /path/to/zf2-app/public
<Directory /path/to/zf2-app/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
</Directory>
</VirtualHost>
Nginx setup
To setup nginx, open your /path/to/nginx/nginx.conf and add an
include directive below
into http block if it does not already exist:, (*18)
http {
# ...
include sites-enabled/*.conf;
}
Create a virtual host configuration file for your project under /path/to/nginx/sites-enabled/zf2-app.localhost.conf
it should look something like below:, (*19)
server {
listen 80;
server_name zf2-app.localhost;
root /path/to/zf2-app/public;
location / {
index index.php;
try_files $uri $uri/ @php;
}
location @php {
# Pass the PHP requests to FastCGI server (php-fpm) on 127.0.0.1:9000
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path/to/zf2-app/public/index.php;
include fastcgi_params;
}
}
Restart the nginx, now you should be ready to go!, (*20)
Features
-
Ready to environment-specific application configuration (futher information about it):, (*21)
-
You can set the current application environment (Apache 2 example):, (*22)
SetEnv APP_ENV "development", (*23)
-
You can use anywhere the constant APP_ENV to retrieve the current environment, (*24)
-
Update the file config/application.config.php, you can configure:, (*25)
- Default Enviroment (if none is set)
- Default Modules (active in all enviroments)
- Modules per Environment
- Default Module Listener Options
- Module Listener Options per Enviroment
-
Comes with Robo (task runner for PHP) and prepared with some useful commands:, (*26)
Clear
Executes all clear commands at once. It will remove any files from dist subfolders (css, fonts, js and img)., (*27)
Usage:, (*28)
vendor/bin/robo clear
Clear Css
Delete all files from dist css folder, by default public/dist/css directory., (*29)
Usage:, (*30)
vendor/bin/robo clear:css
Clear Font
Delete all files from dist fonts folder, by default public/dist/fonts directory., (*31)
Usage:, (*32)
vendor/bin/robo clear:font
Clear Js
Delete all files from dist js folder, by default public/dist/js directory., (*33)
Usage:, (*34)
vendor/bin/robo clear:js
Clear Image
Delete all files from dist image folder, by default public/dist/img directory., (*35)
Usage:, (*36)
vendor/bin/robo clear:img
Dist
Executes all dist commands at once., (*37)
Usage:, (*38)
vendor/bin/robo dist, (*39)
Dist Css
Executes three steps commands:, (*40)
- Executes clear:css command.
- Compiles
main.scss and creates the files zff-sprout.css and zff-sprout.min.css in dist css folder (public/dist/css).
- Compiles any css vendors and creates the files
zff-sprout-vendors.css and zff-sprout-vendors.min.css also in dist css folder.
Usage:, (*41)
vendor/bin/robo dist:css
Dist Font
Executes two steps commands:, (*42)
- Executes clear:font command.
- Copy any font vendors to dist fonts folder (
public/dist/fonts).
Usage:, (*43)
vendor/bin/robo dist:font
Dist Js
Executes three steps commands:, (*44)
- Executes clear:js command.
- Concat any js file in
public/js and creates the files zff-sprout.js and zff-sprout.min.js in dist js folder (public/dist/js).
- Concat any js vendors and creates the files
zff-sprout-vendors.js and zff-sprout-vendors.min.js also in dist js folder.
Usage:, (*45)
vendor/bin/robo dist:js
Dist Js
Executes two steps commands:, (*46)
- Executes clear:two command.
- Copy any img file in
public/img to dist images folder (public/dist/img)
Usage:, (*47)
vendor/bin/robo dist:img
Watch
Executes all watch commands at once., (*48)
Usage:, (*49)
vendor/bin/robo watch
Watch Composer
Monitors the composer.json file and when it changes composer update will be executed., (*50)
Usage:, (*51)
vendor/bin/robo watch:composer
Watch Css
Monitors all files in public/css folder and when anyone changes the command dist:css will be executed., (*52)
Usage:, (*53)
vendor/bin/robo watch:css
Watch Font
Monitors all files in public/font folder and when anyone changes the command dist:font will be executed., (*54)
Usage:, (*55)
vendor/bin/robo watch:font
Watch Js
Monitors all files in public/js folder and when anyone changes the command dist:css will be executed., (*56)
Usage:, (*57)
vendor/bin/robo watch:css
Watch Img
Monitors any file in public/img folder and when it changes the command dist:img will be executed., (*58)
Usage:, (*59)
vendor/bin/robo watch:img
Todo List