Environment and workflow

As a developer, you will have your own environment with which you need to feel confident enough, and which can actually help you writing the code without many worries. If you do feel that there's a gap between writing the code and seeing the actual result, then there's something you need to fix.

It's quite important for the purpose of this book to outline my optimal environment that I will use throughout the upcoming chapters and code samples that you will find.

I will, of course, note when the environment might make a difference, but be wary that, if your environment is different, you may need to check the developer's documentation or reach out to anyone who might know the answer, in case something is not working.

My personal development environment is composed of the following:

  • A robust Integrated Development Environment (IDE), such as IntelliJ PHPStorm, rather than a simple code editor (for example, VIM): You get some additional benefits from it, for example, an integrated debugger, a syntax checker, a code hinting system, and so forth.
  • A modern version control system (for example, GIT): Commit always and often. It's the only way for you to understand the history and control the changes in your project in a sensible way. Head over to http://git-scm.com/doc if you need more information and learn by visually experimenting with it at http://pcottle.github.io/learnGitBranching/.
  • Linux Apache MariaDB PHP (LAMP) box packaged as a virtual machine: I've passed through the stage of having my own machine acting as my LAMP box, but this has proved to be too unreliable for many reasons. Mostly because after a while, you will end up confusing experimental plugins and tools that are not meant to be used on certain projects, potentially messing up your work.

A development or testing environment is usually quite simple to set up as it won't require an extensive configuration, as it would do in a critical or production environment.

One of the reasons in favor of having such an environment setup, in particular with reference to the LAMP box, is the ability to configure it as you wish based on the project you're working on, and in particular being able to replicate the live/production environment as close as possible. This has a clear advantage when it comes to the following:

  • Working within a team with more than one developer
  • Replicating bugs occurring on any environment (for example, test, stage, or live)

Vagrant is probably the tool you're looking for if you want to start easy (see http://www.vagrantup.com/), and if it convinces you, it might be worth giving the book, Creating Development Environments with Vagrant, Michael Peacock, Packt Publishing, a shot (http://www.packtpub.com/creating-development-environments-with-vagrant/book).

PHP does not need major adjustments, and I believe a default PHP installation will suffice to get you started as this is the only constraint for running Yii 2. Be sure to have a version equal to or above 5.4, and have a CLI PHP available on the command line, by issuing the following command:

$ php –v
PHP 5.5.22-1+deb.sury.org~precise+1 (cli) (built: Feb 20 2015 11:25:06) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

The preceding output is from a Vagrant machine running Ubuntu 12.04 with PHP 5.5 installed.

The dollar sign ($) means the command can be run by a user and you won't need administrative permissions to run it.

If you get a command not found error, be sure to refer to your distribution/OS vendor for support on how to install it. Most of the distributions provide it by default, while others require additional configuration parameters or packages.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset