Magento is an open-source eCommerce stack with smart features such as layered navigation, auto-complete search, multiple language support, multiple stores, smart browsing, RSS product feeds, tagging and reviewing products, reviewing search terms, reviewing customer tags, poll manager, currency exchange rates, Google sitemap integration, abandoned shopping cart report, catalog-wide product comparisons, product wish lists, and even zooming the product image. It was created by Varien, based on the top notch MVC framework—Zend Framework, on March 31, 2008. As with other MVC applications, Magento keeps the display logic separated from the application’s business logic. A dedicated team works on updating Magento regularly.
Magento Developer is a very hands-on role for both a novice and experienced software engineer who is interested in achieving high impact in a fast-paced development environment with an ambitious mission. Magento gives a very handy way to deal with its features faster than any other alternatives, whether you know a little or a lot about PHP programming. Let’s see how these things happen.
We will make our development platform ready to cook some mouth-watering recipes for Magento in this article. If you are a newbie, this is the right place to start. If you are a pro, this is still the right place to start as we have tried to follow some best practices for Magento development that you might not be aware of. Let’s get our hands dirty with Magento Development! Good luck!
Magento is built on the de facto PHP framework—Zend Framework. We need to set up our development environment properly to get most out of it. In this recipe, we will set up a Fully Qualifed Domain Name (FQDN) and a virtual host. We could use the domain as http://localhost/magento or something like this, but in that case accessing the admin panel might be cumbersome. In most cases, you have to access through the local IP address. Using a FQDN, you don’t have to worry about it. A FQDN will make the debugging process much easier also.
We need to have the following things installed before kicking off the setup of a virtual host a.k.a. vhost:
If we want to install the previously mentioned tools from Ubuntu Linux CLI, we can easily do that by running the following commands. We will be using Linux commands based on Ubuntu.
The following command is a basic Apache installation command:
sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
The following command is a basic PHP5 installation command:
sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5- mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl
Enter the following command to begin with a simple MySQL installation:
sudo aptitude install mysql-server mysql-client libmysqlclient15-dev
Note that we have installed the development libs and headers with the libmysqlclient15-dev package. You can leave that out but it has been found that they are useful in many situations.
Alternately, we can use an all-in-one package, such as the XAMPP, to get all the aforementioned tools in one click. The XAMPP package can be downloaded from http://www.apachefriends.org/en/xampp.html.
sudo nano /etc/hosts
127.0.0.1 magento.local.com
The location of the host file depends on the OS loaded. If it’s a Windows OS it should be c:windowssystem32driversetchosts.
cd /var/www/
If you are using XAMPP, it would be c:xampphtdocs.
mkdir -p magento.local.com/{public,private,log,cgi-bin,backup}
sudo nano /var/www/magento.local.com/public/index.html
<html> <head> <title>Welcome to magento.local.com</title> </head> <body> <h1>Welcome to magento.local.com</h1> </body> </html>
sudo nano /etc/apache2/sites-available/magento.local.com
# Place any notes or comments you have here # It will make any customization easier to understand in the weeks to come # domain: magento.local.com # public: /var/www/magento.local.com/public <VirtualHost *:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin webmaster@magento.local.com ServerName magento.local.com # Index file and Document Root (where the public files are located) DirectoryIndex index.php index.html DocumentRoot /var/www/magento.local.com/public # Custom log file locations LogLevel warn ErrorLog /var/www/magento.local.com/log/error.log CustomLog /var/www/magento.local.com/log/access.log combined </VirtualHost>
sudo a2ensite magento.local.com
sudo /etc/init.d/apache2 reload
Tada! We now have the contents of public/index.html being shown.
The Getting ready recipe describes the installation process of Apache, PHP, and MySQL from Linux command line. If you have already installed those, you can skip it and start confguring the layout and vhost directly.
The Magento source files will be put in the public directory. Other directories represent as their name suggest. Usually in production server, we don’t have to write the domain name manually as we wrote here, as the DNS zone is there. The rest of this recipe is the same as the production server. The virtual host contents has some inline comments starting with # to describe the purpose.
A Subversion is a popular version control system initiated in 2000 by CollabNet Inc. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS).
If you are a Windows user, please download the TortoiseSVN client from here: http://tortoisesvn.tigris.org/ and if you are a Linux user, fre up your terminal.
sudo apt-get install subversion
Make sure you have an active Internet connection as aptitude will install the package from Ubuntu repository.
If you are using windows and intended to use TortoiseSVN you may get a Windows binary from http://tortoisesvn.tigris.org.
sudo addgroup subversion sudo adduser <your_username_here> subversion
If you don’t a have a clue about your current username, issue the command whoami in your terminal.
sudo mkdir /home/svn cd /home/svn sudo mkdir magento sudo chown -R www-data:subversion magento sudo chmod -R g+rws magento
sudo svnadmin create /home/svn/magento
cd /var/www/magento.local.com
svn co file:///home/svn/magento public
When we execute any apt-get command, the aptitude will take care of the installation process. The aptitude will look for the package from Ubuntu central repository—and download it if necessary—and perform the necessary tasks.
After completion of the installation process, we’ve created a new group named subversion and added the username to the newly created group subversion. Then we’ve created a directory under /home/location to hold all repositories. After that, we’ve created a new repository for our Magento project named magento. Finally, we’ve checked out the repository in our site location in the public directory.
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…