Skip to content

Portable development environment in Windows

A) Eclipse IDE
Download and unzip « Eclipse Classic » version of Eclipse IDE :

http://www.eclipse.org/downloads/ or directly from http://www.eclipse.org/downloads/packages/eclipse-classic-421/junosr1

Define a relative path to the workspace directory (for example: ..\..\dev\workspace\)
Install all PHP/Symfony2 development plugins:

1 – PDT: http://download.eclipse.org/tools/pdt/updates/release

2- Yaml: http://dadacoalition.org/yedit

3- (optional) Twig, JsonEdit, Composer http://pulse00.github.com/p2/

Configure the eclipse editor :

1- Define UTF8 for all text editors : Preferences -> General -> Workspace -> Text file encoding

2- Define Tab size as 4 spaces : Preferences -> General -> Editors -> Text Editors

3- Define default php version to PHP5.3 or greater : Preferences ->

B) LAMP environment
Download and unzip xampp compressed version :
or directly from here :

Now we should configure xampp if we don’t use it from root directory (e.g c:\xampp) – from xampp directory

php\php.exe -n -d output_buffering=0 install\install.php usb

C) Install and activate xdebug
1- check phpinfo output and download the right dll version of xdebug
http://xdebug.org/find-binary.php
2- copy dll to php\ext folder
3- update php.ini xdebug section :

	[XDebug]
	zend_extension = "D:\xampp\php\ext\php_xdebug-2.1.2-5.3-vc9.dll"

D) Download and install PHPUnit
1- update PEAR package :

get and copy localy "go-pear.phar" from : http://pear.php.net/go-pear.phar
run : php go-pear.phar


D:\dev\php\xampp\php> php.exe go-pear.phar

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] : local
Please confirm local copy by typing 'yes' : yes

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : \dev\php\xampp\php
 2. Temporary directory for processing            : \dev\php\xampp\php\tmp
 3. Temporary directory for downloads             : \dev\php\xampp\php\tmp
 4. Binaries directory                            : \dev\php\xampp\php
 5. PHP code directory ($php_dir)                 : \dev\php\xampp\php\pear
 6. Documentation directory                       : \dev\php\xampp\php\docs
 7. Data directory                                : \dev\php\xampp\php\data
 8. User-modifiable configuration files directory : \dev\php\xampp\php\cfg
 9. Public Web Files directory                    : \dev\php\xampp\php\www
10. Tests directory                               : \dev\php\xampp\php\tests
11. Name of configuration file                    : \dev\php\xampp\php\pear.ini
12. Path to CLI php.exe                           : \dev\php\xampp\php

2- install PHPUnit :

pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

E) Optional : configuring Apach virtualhost
1- create « conf » folder to hold all project specific configurations
ex: « /dev/php/conf/vhost »

2- add a virtual host config file:


    DocumentRoot "/dev/php/workspace/myproject/web"
    ServerName myproject.local
    ErrorLog "/dev/php/workspace/myproject/logs/error.log"
    CustomLog "/dev/php/workspace/myproject/logs/access.log" combined
	
		Options FollowSymLinks
		Order Allow,Deny
		Allow from all
		Require all granted
	

3- include these configuration in apache virtual host config file (D:\dev\php\xampp\apache\conf\extra\httpd-vhosts.conf)

...
Include "/dev/php/conf/vhost"

E) Optional : stock mysql database file locally
1- create « db » folder to hold all project specific database files
ex: \dev\php\db

2- if the project database is myprojectdb, then we create the « myprojectdb.sym » file in masql data directory
ex: \dev\php\xampp\mysql\data\myprojectdb.sym

3- add these configurations to « myprojectdb.sym » file

\dev\php\db\myprojectdb
Publicités

Debian logrotate Configuration

When we work on a symfony project, we have probably a lot of log files to manage. One of the easiest ways is using Linux logrotate program. In Debian we can install it by apt-get command.

Install logrotate :

#apt-get install logrotate

Now we can configure it to rotate our symfony project logs by creating a project specific config file in general config directory of logrotate e.g /etc/logrotate.d :

#vi /etc/logrotate.d/myproject

#/etc/logrotate.d/myproject
/home/myproject/log/*.log {
        olddir /home/myproject/oldlogs
        daily
        missingok
        rotate 30
        size 10M
        compress
        delaycompress
        notifempty
        sharedscripts
        postrotate
                echo logs rotated at : `date "+%Y-%m-%d %H:%M:%S"` >> /home/myproject/log/oldlogs/logrotate.log
        endscript
}

Git for a portable development environment on Windows

Portable Git

As an ideal development environment, I sugest a portable one. I build my own developement environment on a USB flash memory and I use it on any Windows environment.

Now if I want to use Git on Windows witout any hard installation, my choice is msysgit. There is no installation and it works perfectly.

1- download and unzip msysgit (http://code.google.com/p/msysgit/)

2- launch the Git console by running : git-bash.bat

Update symfony 2 project with composer

  1. grab composer.json and composer.lock from desired version of symfony 2 Standard Edition package
  2. change « minimum-stability » from « dev » to « stable » in composer.json
  3. add in additional bundle dependencies in composer.json
  4. run composer update so a new composer.lock file is generated
  5. delete the vendor directory and run composer install as normal
php composer.phar create-project symfony/framework-standard-edition path/ 2.1.3

We can say :

# To install 
$ php composer.phar install
# To update 
$ php composer.phar update

# To add, remove or change dependencies : edit composer.json
$ php composer.phar update

Manage Apache virtual hosting files in Windows

1- create a text file for all project virtual host configurations in project directory « c:\dev\myproject\conf\vhost »

2- edit file and add virtual hosting conigurations

<VirtualHost *:80>
   DocumentRoot "/dev/php/workspace/saphirnet/web"
   ServerName saphir.local
   ServerAlias www.saphir.local
   ErrorLog "/dev/php/log/error.log"
   CustomLog "/dev/php/log/access.log" combined
   <Directory "/dev/php/workspace/saphirnet/web">
       Options FollowSymLinks
       Order Allow,Deny
       Allow from all
       Require all granted
   </Directory>
</VirtualHost>

3- add it to apache vhost config by Include command Include

Include "/dev/myproject/conf/vhost"

Manage MySQL data files in Windows

In linux environment, we can use symbolic links to manage MySQL data file and stock them physically anywhere in the project. The main advantage is data protection if MySQL  would be re-installed. In Windows thing are a little more complicated because there is no symbolic link at all. We can arrange it by creating a *.sym file in MtSQL data directory.

1- create project database storage directory c:\dev\myproject\data\

2- if project database named myprojectdb and mysql is installed in c:\xampp\mysql\, create a simple text file here c:\xampp\mysql\data\myprojectdb.sym

3- edit  myprojectdb.sym and add a link to physical storage directory c:\dev\myproject\data\

Beginning Drupal 7

I start with drupal 7 but as soon as version 8 is available, I’ll upgrade to Drupal 8.

Installation :

– Download and unzip drupal archive to project directory (http://drupal.org/project/drupal)

– Prepare vhost

– Create a database for drupal project and grant a database user to this database.

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `drupal_drupal7`.* TO ‘dradmin’@’localhost’ IDENTIFIED BY ‘123456’;

– Project settings

Copy the default.settings.php to settings.php

– Run the installation script

1- standard option

2- language setting

Follow these steps to translate Drupal into your language:

  1. Download a translation from the translation server.
  2. Place it into the following directory:
    /profiles/standard/translations/

3- Verify requirements(done)

4- Set up database

5- Install profile(active)

6- Configure site