initialize magento from php shell interface

Magento can be run on php command line. All it needs is to include the Mage.php file. Assume you have Magento installed on your machine, then you can enter the php interactive shell interface, include the Mage.php, call Mage::app(); to initialize Magento, and you will be able to use all sorts of Magento functions that starts with Mage such as these


Here is a series of commands on the command line does what’s described above.

$> php -a
Interactive shell

php > include "/Users/pye/dev/bookspan-mage/app/Mage.php";
php > Mage::app();
php > $customer = Mage::getModel('customer/customer')->load(55250403);
php > echo $customer->getEmail();
php > 

These can also be written in a php file and the result will be the same by running the php file. php test.php

include "/Users/pye/dev/bookspan-mage/app/Mage.php";
$customer = Mage::getModel('customer/customer')->load(55250403);
echo $customer->getEmail();

Search within Codexpedia

Custom Search

Search the entire web

Custom Search