Magento not working on PHP 5.3
August 19, 2009 51 Comments
For those who have noticed this error
Fatal error: Method Varien_Object::__tostring() cannot take arguments in /magento/lib/Varien/Object.php
when trying to install Magento on PHP 5.3, do not fear, here is the fix:
File: /lib/Varien/Object.php (Line 484)
Change from
public function ___toString(array $arrAttributes = array(), $valueSeparator=’,')
To this
public function __invoke(array $arrAttributes = array(), $valueSeparator=’,')
File /app/code/core/Mage/Core/Controller/Request/Http.php (Line 274)
Change from
$host = split(‘:’, $_SERVER['HTTP_HOST']);
To this
$host = explode(‘:’, $_SERVER['HTTP_HOST']);
Thanks, it works perfectly for me.
Thank you!
You are the man!
Thanks a lot! It works perfectly.
Thanks!! works perfect!! cheers!!
It works but later on when you try to add products and other tasks you get errors similar to
“Function split() is deprecated in ………line xxx”
At which time you need to change the split() to explode()
Or is it just me getting these errors.
Thanks a ton. Just Saved my day. I was about to install a lower version of WAMP..
Pingback: PHP 5.3 and Magento | The nocturnart blog
Thanks Dear it’s realy worked
Thanks! It worked!
Your a legend, After installing Snow Leopard, it all went wrong but now works fine following your fixes. well done
Your solution is incomplete, after you change the __toString to __toInvoke, add this:
function __toString() {
return $this->__invoke( func_get_arg(0), func_get_arg(1) );
}
Tried it then got this error : Parse error: parse error, expecting `’&” or `T_VARIABLE’ in C:\lib\Varien\Object.php on line 498
Rob
The two lines get you pass the installation error
BUT
Note that there are two typos in the correction lines (an apostrophe is used in the end of the lines instead of the single quote):
The correct lines are:
public function __invoke(array $arrAttributes = array(), $valueSeparator=’,')
AND
$host = explode(‘:’, $_SERVER['HTTP_HOST']);
Thanks Idrees Haddad, have noted the mistakes and corrected it.
[UPDATE]
I don’t know why BUT after posting the comment the single quote gets changed to apostrophe.
Correct the first line: at the end before the comma , should be single quote.
Correct the second line: before the colon should be a single quote too.
Ok, this looks like WordPress is causing this.
Are you a professional journalist? You write very well.
There is another file that needs to be changed
File /app/code/core/Mage/Admin/Model/User.php (Line 374)
From:
$nodePath = ‘adminhtml/menu/’ . join(‘/children/’, split(‘/’, $startupPage)) . ‘/action’;
To
$nodePath = ‘adminhtml/menu/’ . join(‘/children/’, explode(‘/’, $startupPage)) . ‘/action’;
Thanks alvin, this was the missing step.
Pingback: De eerste install » CustomizeMagento.net Blog
I read a few topics. I respect your work and added blog to favorites.
In truth, immediately i didn’t understand the essence. But after re-reading all at once became clear.
hi, thanks. Its perfectly works. then could you guide me how to install sample data on magento 1.2.0
You have to copy the sample data files into the the magento folder, run the SQL script that comes with it then install magento. I believe there is good tutorial in the documentation section on Magento site.
thanks a million!
Very interesting and amusing subject. I read with great pleasure.
Thank you worked a treat
Great, worked for me!
Thanks man!!!! It’s great!!!! worked very well for me!
Fine thanks
Hi,
Thanks you saved my day. I was new to Magento and such errors would have blown my mind.
Thanks again
Thanks very much, this helps a lot, working now, hehehe.
thanks!! great solution.
Thanks for sharing this fix. Keep it up.
I was about to downgrade but got your fix. You are a life saver.
split() is deprecated so you need to change all instances of split to explode();
Thanks a lot.
not sure if it’s because i’m on windows 7, but no matter what i try i still end up with errors after sorting out the configuration part, which gives an error code (can’t remember just yet bu tihnk it was 8109) and then when i refresh another error messages, which wont go until i dlelete everything and start again for the hundreth time
Pingback: GUYA.NET » Blog Archive » Pitfalls to avoid when installing Magento on XAMP
There is even an easier way to fix this – just change the Varien_Object::__toString() as follows:
public function __toString()
{
if(func_num_args() > 0)
{
$arrAttributes = func_get_arg(0);
}
else
{
$arrAttributes = array();
}
if(func_num_args() > 1)
{
$valueSeparator = func_get_arg(1);
}
else
{
$valueSeparator = ‘,’;
}
$arrData = $this->toArray($arrAttributes);
return implode($valueSeparator, $arrData);
}
That worked perfectly.
Very easy to follow instructions! Good work!
Great!! It works perfectly for me. Thank you very much
works perfectly for me! Thank you so much!
Why haven’t the Magento folks fixed this yet? It’s June, 2010.
it’s not working for me i got an error
Parse error: parse error, expecting `’&” or `T_VARIABLE’ in G:\wamp\www\pro\lib\Varien\Object.php on line 485
hello did u find solution for this parse error, if yes please help me I couldn’t found it, thank u in advance
another one place you have to convert replace split into explode
app\code\core\Mage\CatalogIndex\Model\Aggregation.php
Line no:154
Function name: function _processTags
This is perfectly working in Magento ver. 1.3.1
I used that really.. But this two place missing to replace split into explode..
app\code\core\Mage\CatalogIndex\Model\Aggregation.php
Line no:154
Function name: function _processTags()
app\code\core\Mage\Admin\Model\User.php
Line no:361
Function name: getStartupPageUrl()
Perfect thank you for this – works perfectly.
You have a great blog here, I really love the way you write
very simple and to the point. Keep your good work coming.
Thank you thank you thank you!!!
Pingback: Running magento on PHP 5.3 « Blogicia
The main implementation of PHP is now produced by The PHP Group and serves as the formal reference to the PHP language. PHP is free software released under the PHP License, which is incompatible with the GNU General Public License due to restrictions on the usage of the term PHP. Thanks.