Book Image

Magento 1.8 Development Cookbook

By : Bart Delvaux, Nurul Ferdous
Book Image

Magento 1.8 Development Cookbook

By: Bart Delvaux, Nurul Ferdous

Overview of this book

<p>Magento is an open source e-commerce platform which has all the functionality to function from small to large online stores. Its architecture makes it possible to extend the functionalities with plugins where a lot of them are shared by the community. This is the reason why the platform is liked by developers and retailers.</p> <p>A practical developer guide packed with recipes that cover all the parts of Magento development. The recipes will start with the simple development exercises and get the more advanced as the book progresses. A good reference for every Magento developer!</p> <p>This book starts with the basics. The first thing is to create a test environment. Next, the architecture, tools, files and other basics are described to make you ready for the real work.</p> <p>The real work starts with the simple things like theming and catalog configuration. When you are familiar with this, we will move on to more complex features such as module and database development. When you have survived this, we will move on to the last part of making a shop ready for launch: performance optimization and testing. This book will guide you through all the development phases of Magento, covering the most common pitfalls through its recipes.</p>
Table of Contents (19 chapters)
Magento 1.8 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring the development tools


When you start customizing your Magento store, a good development environment with the following components saves time:

  • A code editor (IDE)

  • A MySQL client (phpMyAdmin or MySQL Workbench)

  • A command-line tool

Getting ready

NetBeans is an open source IDE that can be used for a lot of programming languages. The PHP support is well maintained and there are a lot of integrations with other systems (Git, SVN, and MySQL).

To install NetBeans, you have to download it from their site at http://netbeans.org and run the installer. Make sure that when you download it, you select the PHP version or the full version.

How to do it...

The following steps show you how to create a NetBeans project with the Magento files as the document root:

  1. To create the project, open NetBeans and navigate to File | New Project.

  2. In the dialog window, click on PHP Application with Existing Sources as shown in the following screenshot:

  3. Click on Next and configure the following settings:

    • Source Folder: This field is set to the location of your Magento code

    • Project Name: The NetBeans project name is entered in this field

    • PHP Version: This field is set to PHP 5.3 or higher

    • Default Encoding: This field is set to UTF-8

    The following screenshot gives the sample values for these settings:

    Tip

    When you are working with a version control system (SVN, Git, or something else), it is recommended to check the option Put NetBeans metadata into a separate directory. If not checked, a .nbproject folder is created in your Magento root, which you will not have in your version control system. Another possibility is to add the .nbproject folder in the .gitignore file.

  4. Click on Next.

  5. Configure the following settings:

    • Run as: In our case, this field is set to a local web server

    • Project URL: In this field, enter http://magento-dev.local, the URL that we have configured for Magento

    • Index File: This field is set to index.php

    The following screenshot gives the sample values for these settings:

  6. Click on Finish and your NetBeans project is ready.

How it works...

When the project is started, you see the document root in the left-hand side column of the window. When you double click on a file, the file will open in the main window. In this window, you can view the file's history, format the code, refactor variable names, and a lot more.

There's more…

Behind the development environment in the IDE, a database client and a command-line tool are very useful when developing in Magento.

MySQL client phpMyAdmin

phpMyAdmin is a MySQL client that runs as a web application. It is an easy-to-use tool for direct SQL input in a database.

  1. To install phpMyAdmin, open your terminal and run the following command:

    sudo apt-get install phpmyadmin
    
  2. Follow the installer's instructions.

  3. Edit the /etc/apache2/apache.conf file, and add the following code at the end of the file:

    Include /etc/phpmyadmin/apache.conf
    
  4. Reload the Apache server with the following command:

    sudo service apache2 reload
    
  5. Go to http://magento-dev.local/phpmyadmin, and you will see the login screen. You can log in with the credentials of the database user for your Magento database.

Command-line tool Wiz

Magento has a lot of system tasks that you have to execute in your development process. All these actions could be triggered in the backend. However, because this is a time consuming job, a shell interface can save you a lot of time.

Wiz is a command-line tool that you can download from https://github.com/classyllama/Wiz.

Follow the installation instructions on their website. When installed, you have to change the directory of your shell to your Magento root. If you are in the Magento root, all the commands you run are executed for that Magento installation.

The following are some useful commands:

  • wiz admin-resetpass: This command can be used when you forget your admin password

  • wiz admin-createadmin: This command creates a new administrative user from scratch

  • wiz cache-clear: This command clears all cache or specific cache

  • wiz devel-showhints: This command enables or disables frontend hints

  • wiz module-list: This command gives a list of all the installed modules

  • wiz sql-cli: This command opens the MySQL command line