0

When attempting to visit my new Magento instance for the first time I recieve the following error:

[05-Jan-2015 13:28:46 America/Chicago] PHP Fatal error:  Call to a member function getModelInstance() on a non-object in /Applications/MAMP/htdocs/magento/magento/app/Mage.php on line 463
[05-Jan-2015 13:28:46 America/Chicago] PHP Stack trace:
[05-Jan-2015 13:28:46 America/Chicago] PHP   1. {main}() /Applications/MAMP/htdocs/magento/magento/index.php:0
[05-Jan-2015 13:28:46 America/Chicago] PHP   2. Mage::run($code = *uninitialized*, $type = *uninitialized*, $options = *uninitialized*) /Applications/MAMP/htdocs/magento/magento/index.php:87
[05-Jan-2015 13:28:46 America/Chicago] PHP   3. Mage::printException($e = *uninitialized*, $extra = *uninitialized*) /Applications/MAMP/htdocs/magento/magento/app/Mage.php:702
[05-Jan-2015 13:28:46 America/Chicago] PHP   4. Mage_Core_Model_App->getStore($id = *uninitialized*) /Applications/MAMP/htdocs/magento/magento/app/Mage.php:920
[05-Jan-2015 13:28:46 America/Chicago] PHP   5. Mage_Core_Model_App->_getDefaultStore() /Applications/MAMP/htdocs/magento/magento/app/code/core/Mage/Core/Model/App.php:815
[05-Jan-2015 13:28:46 America/Chicago] PHP   6. Mage::getModel($modelClass = *uninitialized*, $arguments = *uninitialized*) /Applications/MAMP/htdocs/magento/magento/app/code/core/Mage/Core/Model/App.php:900

I'm using the latest MAMP PRO with PHP 5.4.34. The virtual host resolves and is configured properly, pointing to /Applications/MAMP/htdocs/magento/magento which is where index.php, install.php, etc, are located.

I am attempting to use the sample database and have properly populated the database, the media directory, and the skin directory. I've ensured all file ownership and permissions are correct including removing any additional Mac OS downloaded file security related flags.

David Fells
  • 6,678
  • 1
  • 22
  • 34

2 Answers2

0

I believe the issue is that your server is passing in an incorrect value *uninitialized* for $_SERVER['MAGE_RUN_CODE'] and $_SERVER['MAGE_RUN_TYPE'].

You can test this by opening the index.php file in the Magento root, going down to the bottom and replacing this:

Mage::run($mageRunCode, $mageRunType);

With this:

Mage::run('base', 'store');

If you look above it, Magento is using the $_SERVER variable to determine which code/type to run.

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';

/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';

This is essentially used for multi-site Magento environments so Magento can switch stores based on the domain/server variables.

If the above test I've provided fixes the issue, look into why your server is returning *uninitialized* for the $_SERVER variables, instead of PHP determining they are not set.


You can also try setting the Magento environmental variables within the MAMP Pro interface which may fix the issue. If you use this solution, you can revert any modifications made to your index.php file (I'd recommend not making any permanent changes to it in the first place).

Go to Hosts, select the server you are running Magento on the left, and click Extended on the right.

In the Additional Parameters for , enter the following:

SetEnv MAGE_RUN_CODE "base" # put here your website or store code
SetEnv MAGE_RUN_TYPE "website" # put here 'website' or 'store'

MAMP Pro v 3.0.3

Tip provided per this StackOverflow answer.

Community
  • 1
  • 1
Axel
  • 10,732
  • 2
  • 30
  • 43
  • I'm using the default files from the Magento 1.9 archive. There are no changes to any files. – David Fells Jan 07 '15 at 03:49
  • Ok? Did you try any of the solutions I've provided? – Axel Jan 07 '15 at 03:54
  • Tried the MAMP stuff, no go – David Fells Jan 08 '15 at 03:53
  • Well it's a good thing that I also provided ways to debug and find the cause (editing the index). If you're not going to to leverage all the information I spent the time to provide to you, then don't expect to come to a resolution, or get closer to solving your issue. – Axel Jan 08 '15 at 03:55
  • Well since the stuff you posted didn't work, I'm not sure what else you want from me? – David Fells Jan 09 '15 at 04:56
  • I'm telling you, the problem is the '*uninitialized*' value being passed into the Magento core. Determine why it's doing that and you'll solve the problem. – Axel Jan 09 '15 at 04:59
0

I think this issue is mostly due to Folder Permissions of the magento. Try to change the folder permissions to 777 by using chmod 777 -R and once it works fine, then you can revert it back to 775 by using chmod 775 -R

Pavan Kumar
  • 1,735
  • 2
  • 28
  • 47