Multi-plataform development notes

If you have a Windows box to develop web applications and then, for production and quality, uses Unix / Linux box you should know that there are some little things that you should take care of. No need to mention the fact that on Unix / Linux everything is case sensitive and on not on Windows (even knowing that Apache threats everything as case sensitive on Windows) is the number one thing that can break if you are migrating from Windows to Unix / Linux, but there are some functions that might work differently and break if you don’t take a more chirurgical look.

For a smart and small example take a look on the mkdir function from php. All you need to do is enter the path, writing mode (chmode) and if is recursive. On a Windows box if you enter something like mkdir($path,’0777’,true) or mkdir($path,0700,true) it will create the folders in the path but will as well set them as writable, even if you said not to, but on Unix and Linux that would not work.

Take a look on the first function, mkdir ( $path , ‘0777’ , true );

If you set your script to create the folder path like this in a UNIX box, it will be created, but the permissions will be wrong. The second argument for the function is an integer and not a string, therefore the permissions would not be created correctly and if you tried to upload a file to the directory, it would fail on permission denied. On a Windows box this is totally bypassed.

Another thing to consider is the way that Windows creates the path. If you use something like c:\path\to\root it will fail on a UNIX or Linux box. To avoid this you need simply change the back slash for the forward slash (c:/path/to/root). This will work on both platforms’.

Small cares like this can make your life way easier while developing in PHP.

Have fun.

About mcloide

Making things simpler, just check: http://www.mcloide.com View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: