Categories
PHP

My LAMP Environment

Today, I am gonna share a short overview of my work environment. I’m gonna detail on how you can setup yours too. First lets get to the L part. I am running Ubuntu Linux 11.04. Well, I do hate the default Unity UI. But good lord, we have the fall back options like “Ubuntu Classic” which is Gnome I believe. After installing Ubuntu, I installed the LAMP server using the “tasksel” utility. I love it because it’s handy and lets me do all sort of package management and software installation based on the nature of task. By default, in Ubuntu 9.10+ versions, we no longer have “tasksel” installed by default. So, open your terminal and get the utility from the repository by executing the following command:

Now that we have tasksel installed, we can install all the packages necessary for LAMP server using another handy command:

Man, I love this terminal and command line geekery! It’s just feels like magic! We’re done setting up the LAMP server. Visit : http://localhost/ and you’ll get the local web page 🙂

Now, the www folder is located to “/var/www” which is owned by the user “root”. So, we take the ownership :

Aha! Now you can create files and directories in the www directory and enjoy!

Well, now if we need to enable a custom apache module, we do this:

It’ll display a list of available modules, type in the ones you need and press enter. After selecting the modules, type this command to reload apache:

Now that we have apache, mysql and php running, lets install some GUI tools for mysql. Here goes the commands:

So far we have installed the basic tools, now lets install PEAR 🙂

Now that you have PEAR, we can install a nice utility – “pman”.

Pman is handy for command line php documentation. Just try like this:

It’ll give the docs for the strlen function on the terminal just like the linux man utility 🙂 Press “q” to quit the man page.

By default, php doesn’t come with curl and gd in linux. Install them like this:

Now that we have a working LAMP setup, lets get some additional tools: SVN, Git and Filezilla.

Ubuntu has Gedit, a text editor with Syntax highlighting. While Gedit can be used for PHP development, most of the popular PHP IDEs have their Linux version. I have used both Netbeans and PhpStorm on Ubuntu. And I know Eclipse run on Linux as well. So fire up your favorite IDE and storm the LAMP arena! 🙂

Categories
PHP

Running WAMP Server at Windows Startup

While using Linux, the LAMP stack was always ready to work on. But on Windows, I have to manually start the WAMP server. This is a pain in the ass! 😛

Today I found a way to run WAMP server at startup. I’m going to share how.

# Go to start menu.
# Right click on My Computer
# Click Manage
# In the “Services and Applications” section, find “wampapache” and “wampmysqld”.
# To start these services on Windows Startup, double click on each of them, set startup to Automatic.

Restart your PC to see if it works 🙂

PS: We are only starting the apache and mysql servers on startup. So don’t expect the WAMP icon in the taskbar. Visit localhost to see if the server is online 🙂

Categories
PHP

Zend Framework: Debugging and Loading Custom Ini

Another blog post for self documentation 😉

Debugging:
Create a init() method in the controller. Put the following codes to disable the layout and turn off view rendering. Now, use print_r(), var_dump() or try…catch whatever you like 🙂

Please note: please make sure if you have any layout enabled already, if you don’t have one, trying to disable the layout will obviously go wrong. In that case, uncomment the respective line.

Even without all these hassles, anywhere in your controller you can use Zend_Debug::dump() which works like var_dump(). But it won’t work in case there is an Application Error (a fatal error somewhere). So, try…catch is a better debugging solution when you can’t trace the source of the problem. For a quick debugging, use Zend_Debug::dump().

Loading Custom Ini

Create a ini file in the “application/configs/” directory. Lets name it mydata.ini. Then create a block of data like this:

Now, you can load these configuration anywhere using the following codes:

The second parameter of the Zend_Config_Ini constructor loads a specific block from the ini file.