Catalogue
A One-Liner Every PHP Engineer Should Run

A One-Liner Every PHP Engineer Should Run

🌐 日本語で読む

This is the ultimate one-liner from hiraku-san that makes everyone happy.

1
$ composer config -g repositories.packagist composer http://packagist.jp

Installing with composer becomes dramatically faster.

The reason it’s slow is apparently that packagist.org is located in France.

A Problem Arises

Let’s run the one-liner above right away!!

And then…

1
2
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Do not run Composer as root/super user! See https://getcomposer.org/root for details

It’s complaining that xdebug is enabled…

Finding Where xdebug Is Configured

1
2
3
4
5
6
7
$ php -i | grep xdebug

/etc/php.d/xdebug.ini,
xdebug
xdebug support => enabled
...
...

It was configured in /etc/php.d/xdebug.ini.

Note: depending on your environment, it may be configured in php.ini, etc., so be careful.

Changing the xdebug Setting to disabled

Since I had no need to use xdebug in my own PHP runtime environment,
I moved /etc/php.d/xdebug.ini out of the way:

1
mv /etc/php.d/xdebug.ini /etc/php.d/xdebug.ini.org

Running Again

Huh… it showed up again… This time:

1
Do not run Composer as root/super user! See https://getcomposer.org/root for details

It’s complaining that I shouldn’t run it as the root user…

Switching to a Regular User Instead of root

1
# su - <user>

Running Again

Success!

1
2
$ composer config -g repos.packagist composer https://packagist.jp
$

Verifying the Configuration

Confirm that the packagist url is now https://packagist.jp:

1
2
3
4
5
6
7
8
9
10
11
$ cat .composer/config.json

{
"config": {},
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.jp"
}
}
}

Enjoy a good PHP life!

References

kenzo0107

kenzo0107