2017 © Pedro PelĂĄez
 

project silex-grunt-skeleton

A pre-configured skeleton for the Silex microframework with Grunt tasks added

image

microstudi/silex-grunt-skeleton

A pre-configured skeleton for the Silex microframework with Grunt tasks added

  • Friday, January 29, 2016
  • by microstudi
  • Repository
  • 1 Watchers
  • 2 Stars
  • 52 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 240 Forks
  • 1 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

ABOUT

Just another Silex-Framework Skeleton, (*1)

This is a port from the https://github.com/silexphp/Silex-Skeleton with this features added:, (*2)

  • Built-in PHP server (minimum version required 5.4)
  • Livereloading for any css, js, or php file changes
  • Demo class with view, phpunit test and route
  • Grunt for automating tasks
  • Bower to install javascript packages (currently jQuery, Modernizr)

Installation

composer create-project microstudi/silex-grunt-skeleton new_app_path

GRUNT, BOWER & COMPOSER

This tools are required to use this project:, (*3)

  • Grunt is a Javascript task runner that helps to execute repetitive tasks such as:, (*4)

    • Javascript minification
    • CSS minification
    • Image optimizations
    • Package installers
    • Code checks and tests
    • ... so on ...
  • Bower is a dependency manager for common Javascript libraries, (*5)

  • Composer is a dependency manager for common PHP libraries, (*6)

Installing grunt and bower

Grunt is a scripting task tool installable through npm, the Node.js., (*7)

If you want to install nodejs, grunt and bower on Ubuntu 12.04 or 14.04 for the very first time just do:, (*8)

sudo apt-get install build-essential libssl-dev git
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo npm install -g grunt-cli
sudo npm install -g bower

Additionally, you may remove the configuration npm user directory to avoid unexpected permissions problems when using npm as non root user afterwards:, (*9)

sudo rm ~/.npm -rf 

To install Composer on Ubuntu or any other *nix execute this commands:, (*10)

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

For other OS, please refer to the official install guides:, (*11)

Install Grunt: http://gruntjs.com/getting-started Install Bower: http://bower.io/#install-bower Install Composer: https://getcomposer.org/doc/00-intro.md, (*12)

Using grunt

Once you have your copy of Grunt installed you need to install the tasks runners used. To do so you may just execute in the path where you have your copy of the Silex-Skeleton code:, (*13)

npm install

Using bower

Once you have your copy of Bower installed you need to download/update the needed Javascript libraries. To do so you may just execute in the path where you have your copy of the Silex-Skeleton code:, (*14)

bower install

Using composer

Once you have your copy of Composer installed you need to download/update the needed PHP libraries. To do so you may just execute in the path where you have your copy of the Silex-Skeleton code:, (*15)

composer install

After that you're ready to execute any of the task available in the same directory:, (*16)

grunt jshint
grunt phplint
...

Grunt commands

  • Default task: grunt This task is the same as execute as doing: grunt lint It performs static code analysis in order to quick detect mistakes or misspellings, (*17)

  • Code linter: grunt lint Same as default task, (*18)

  • Wiredep grunt wiredep This task is to add into the specified layouts the bower components Should be executed manually every time a bower library is installed, (*19)

  • build grunt build Builds the project into the dist folder. Production web server should point to the "dist/web" folder, (*20)

  • serve grunt serve Starts an instance of the PHP builtin server with livereload pointing to the development folder "web", (*21)

  • serve:dist grunt serve:dist Builds the project and starts an instance of the PHP builtin server with livereload pointing to the production folder "web", (*22)

  • precommit grunt precommit This task could be usefull if you want to add it to the pre-commit git hook. Executes the lint tasks for a a modified files only so you'll prevent from commiting broken files:, (*23)

    Content of .git/hooks/pre-commit:, (*24)

    #!/bin/sh
    grunt precommit
    

    Remember to make it executable:, (*25)

    $ chmod +x .git/hooks/pre-commit, (*26)

TODO:

  • adding optional yml config for assets path (cdn, jquery cdn or cdnfy), google analytics, etc
  • add phpunit to grunt
  • add translations
  • doctrine

The Versions