cancel
Showing results for 
Search instead for 
Did you mean: 

unable to access magento classes via command line interface/vagrant box

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

unable to access magento classes via command line interface/vagrant box

hello everyone 

i installed Magento via a vagrant box. it works fine.

i created a page at the root of the site with following code: 

 

 

 

require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();


$customer = Mage::getModel('customer/customer')->load(79);
print_r($customer->getData());

i then tried to access this page  via command line interface on windows (cygwin) with following commands

 php magento/test.php

 

i get the following errors; 

 

 

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [20 02] No connection could be made because the target machine actively refused it.
' in C:\DevFolder\magentoKlierik\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php:12 9

 

however when i make the same call via the URL i get access. i.e 

 

 

why is there a difference when using  command line and how do i give permission on the command line

 

 

 

3 REPLIES 3

Re: unable to access magento classes via command line interface/vagrant box

Hi,
Possible it is yur cli php settings? When you check phpinfo from command line - do you have everything same as for web version?
____________________________________________
Magento? it's really interesting.. BroSolutions like it Smiley Happy

Re: unable to access magento classes via command line interface/vagrant box

hi

 

thanks for your response

 

i am new to using vagrant. can you tell me which commands i can use to check this?

Re: unable to access magento classes via command line interface/vagrant box

Hi

 

You wrote that you tryto access this page via command line interface on windows (cygwin) with following commands: php magento/test.php

 

You're using the PHP interpreter installed with cygwin, not the PHP interpreter of the Vagrant machine.


You must use the Vagrant machine shell  to run "php magento/test.php"

 

Use putty or use this command: https://www.vagrantup.com/docs/cli/ssh.html

Maxime Coudreuse, developer of Product Manager for Magento: User-friendly product editor with customizable grid interface and category tree for Magento 1 and 2