XF 2.1 Error when trying to create an addon

JohnLogar

Member
Hi,
I just moved from the Linux to Mac OS. I installed the MAMP 5.7 to get a local server setup. But I facing an issue when I create addon by the following command

Code:
php cmd.php xf-addon:create

Once I run the command the following error is showing

Code:
An exception occurred: [XF\Db\Exception] No such file or directory in src/XF/Db/Mysqli/Adapter.php on line 165
#0 src/XF/Db/Mysqli/Adapter.php(28): XF\Db\Mysqli\Adapter->makeConnection(Array)
#1 src/XF/Db/AbstractAdapter.php(60): XF\Db\Mysqli\Adapter->getConnection()
#2 src/XF/Db/Mysqli/Adapter.php(113): XF\Db\AbstractAdapter->connect()
#3 src/XF/Db/AbstractAdapter.php(516): XF\Db\Mysqli\Adapter->escapeString('addOnsComposer')
#4 src/XF/Db/AbstractAdapter.php(494): XF\Db\AbstractAdapter->quote('addOnsComposer')
#5 src/XF/DataRegistry.php(138): XF\Db\AbstractAdapter->quote(Array)
#6 src/XF/DataRegistry.php(83): XF\DataRegistry->readFromDb(Array, Array)

anyone would like to help me with it.

Thanks
 

Chris D

XenForo developer
Staff member
If your src/config.php file contains:
PHP:
$config['db']['host'] = 'localhost';

Then change it to the following which will make it use TCP/IP rather than socket connection:
PHP:
$config['db']['host'] = '127.0.0.1';
 

JohnLogar

Member
Could you please help me to switch the PHP version in MAMP. I need PHP 5.6 which is not available in Preferences. It's only allow to change the latest 2 version 7.3 and 7.4.
 

Chris D

XenForo developer
Staff member
Well I assume that MAMP only includes those versions. I'm not familiar enough with it to know how to add additional versions.

Is there any reason you can't use 7.2, 7.3 or 7.4?
 

Chris D

XenForo developer
Staff member
Ok. I'd recommend working towards PHP 7.0 as a minimum. Significantly XF 2.2 drops support for PHP 5.x entirely so at some point you'll need to be working with PHP 7 for XF development.

As for the MAMP issue I don't know, sorry.

This is the process I follow to set up my dev environment:
It sets up various PHP versions from 5.6 up to the latest using Homebrew and includes a simple way of switching versions.
 

JohnLogar

Member
I understand your recommendation and will definitely work on it to make it compatible with the latest PHP version.

Meanwhile, I think the above link will also work with Mojave 10.14.
 

Chris D

XenForo developer
Staff member
Yeah pretty certain it will. I've run various iterations of that guide over several years. It hasn't changed much in that time.
 

D.C Style

Member
If your src/config.php file contains:
PHP:
$config['db']['host'] = 'localhost';

Then change it to the following which will make it use TCP/IP rather than socket connection:
PHP:
$config['db']['host'] = '127.0.0.1';
not worked for me. Still getting the same error.
 
Top