Laravel Framework

Laravel Framework

README

Almost a year ago I decided to stop using PHP as a language for my projects and decided to start developing all my web type projects using frameworks for Ruby, I can now say I’ve mastered Ruby on Rails and Sinatra.

Even so, and after discussing with several clients my way of working and the technologies that I use to create their projects, I’ve decided to re-take a chance on PHP. Over the years working with this language I used several frameworks (most with MVC - Model/View/Controller paradigm) including Zend, CodeIgniter, Symfony and PHP-Rapyd (the latter even being small helped me to create light projects in a fast way, thanks to Felice Ostuni) and had always chosen the same CMS to offer my clients, currently built on CodeIgniter: PyroCMS but some time ago its developers have decided to migrate this project to Laravel and this is where my story began.

Before continuing, I want to clarify that if I criticize the project Laravel, I’m going to be constructive criticism (I hope). It has been several years since the last flurry of news in the world of web development for PHP developers, and after new ORM’s, new programming paradigms, new database engines (NoSQL mostly), no one had made a big effort to have all these new technologies at hand on the same project.

I was tired of listening to all my clients saying:

  • Hey, I want my website in Wordpress because another company has its website so,
  • My project has to be super safe, so I want to do it in Symfony,
  • My project will grow in the future, we’ll use Zend,
  • I want a unique development with non-relational databases, write code from scratch,
  • Etcetera.

Writing code from scratch? What good web developer do that today? Not that this is an operating system with orphaned applications using custom libraries. My work would not be done as fast if not use a framework in either Ruby, Python, PHP, Javascript, CSS.

After reading so many good reviews about Laravel and after realizing that the only CMS that I would recommend with closed eyes to someone will migrate to this framework, I decided to have a look and write some code… and I fell in love with it as I fell with Ruby on Rails since I wrote my first lines of code in Ruby for the web. It is just fascinating as the work of Taylor Otwell and his partners has grown so much in so little time, Laravel I can ensure that you are giving more life to PHP using its advance and the power of new technologies.

So the only thing left for me to say is Gracias, muchas gracias.

Code

After several attempts to use Laravel in new projects, I decided to create this simple script to generate a basic development environment for my work. This script basically remove all the useless folders and files generated through Composer using the default configuration require-dev and will grant write privileges to the required folders; in my case this script reduced the size of the directory where Composer installed Laravel in more than 80MB from 115MB to 32MB. Well 32MB is very much for a startup project comparing this size with the 316K of a startup project in Rails, but you should know that those 3rd vendor libraries (mostly from Symfony repositories) are very big in size.

$ du -sh project/*
248K    app
4.0K    artisan
344K    bootstrap
4.0K    composer.json
60K     composer.lock
4.0K    CONTRIBUTING.md
4.0K    phpunit.xml
20K     public
4.0K    readme.md
4.0K    server.php
31M     vendor
$ du -sh project/vendor/*
4.0K    vendor/autoload.php
4.0K    vendor/bin
92K     vendor/classpreloader
80K     vendor/composer
4.4M    vendor/doctrine
268K    vendor/filp
68K     vendor/ircmaxell
3.3M    vendor/laravel
556K    vendor/monolog
240K    vendor/nesbot
1.7M    vendor/nikic
2.3M    vendor/patchwork
2.7M    vendor/predis
72K     vendor/psr
8.7M    vendor/swiftmailer
6.4M    vendor/symfony

Laravel Framework 1

#!/bin/bash
IFS=$'\n'
SEPARATOR=$(for i in {1..50}; do echo -n '-'; done; echo)
WRITE_DIRECTORIES=(
    './app/storage/cache/'
    './app/storage/logs/'
    './app/storage/sessions/'
    './app/storage/views/'
)
#
# Create project based on the Laravel framework.
# Alternative: git clone https://github.com/laravel/laravel.git ./
echo -e "Creating project based on the Laravel framework"
composer.phar -vv create-project laravel/laravel ./
#
# Clean up project (remove useless directories).
CURRENT_SIZE=$(du -sh ./ | awk '{print $1}')
DIRECTORIES=()
for DIRECTORY in $(find ./ -type d -iname ".git"); do
    DIRECTORIES+=$DIRECTORY
    echo -e "Removing \e[0;93m${DIRECTORY}\e[0m"
    rm -rf "${DIRECTORY}"
done
FINAL_SIZE=$(du -sh ./ | awk '{print $1}')
echo $SEPARATOR
echo -e "Cleaned up directory: \e[0;91m${CURRENT_SIZE}\e[0m => \e[0;92m${FINAL_SIZE}\e[0m"
echo -e "\e[0;93mGranting write permissions:\e[0m"
for DIR in "${WRITE_DIRECTORIES[@]}"; do
    echo "  ${DIR}"
    chmod 777 "${DIR}"
done
echo -e "\e[0;92mFinished.\e[0m"
Do you have a project idea? Let's make it together!