Created
September 30, 2016 16:00
-
-
Save IvanChepurnyi/776d56770eecd5d3e39bde6ea41f9dca to your computer and use it in GitHub Desktop.
Optimizes autoloader for the best performance on production system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
magentodir=$1 | |
cd $magentodir | |
read -d '' script << PHP | |
<?php | |
\$composer = json_decode(file_get_contents('composer.json'), true); | |
if (!is_array(\$composer['autoload']['psr-0'][''])) { | |
\$composer['autoload']['psr-0'][''] = [\$composer['autoload']['psr-0'][''], 'var/generation']; | |
} | |
if (!isset(\$composer['autoload']['exclude-from-classmap'])) { | |
\$composer['autoload']['exclude-from-classmap'] = ['**/dev/**', '**/update/**', '**/Test/**']; | |
} | |
file_put_contents('composer.json', json_encode(\$composer, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); | |
PHP | |
phpscript=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
echo $script > /tmp/$phpscript | |
php -f /tmp/$phpscript | |
rm /tmp/$phpscript | |
composer config optimize-autoloader true | |
composer dump-autoload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment