mkdir ~/bin
sudo apt install php-cli php-xml
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=bin --filename=composer
php -r "unlink('composer-setup.php');"
Add Composer to PATH environment variable by modifying either ~/.profile
or ~/.bash_profile
.
cp ~/.profile{,.bkp}
cat >> ~/.profile << "EOF"
if [ -d "$HOME/.config/composer/vendor/bin" ] ; then
PATH="$HOME/.config/composer/vendor/bin:$PATH"
fi
EOF
source ~/.profile
composer global require "squizlabs/php_codesniffer=*"
composer global require friendsofphp/php-cs-fixer
Configure php-cs-fixer
for PSR-2 coding style.
cat > ~/.php_cs << "EOF"
<?php
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => [ 'syntax' => 'short' ],
'no_unused_imports' => true,
]);
EOF
{
"caret_style": "phase",
"ensure_newline_at_eof_on_save": true,
"ignored_packages":
[
"Vintage"
],
"line_padding_bottom": 6,
"line_padding_top": 6,
"rulers": [80, 120],
"show_tab_close_buttons": false,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true
}
Install Package control and then the following packages in order with it:
Make sure the config
path points to the previously created .php_cs
file.
{
"config": "/home/juan/.php_cs",
"on_save": true,
"on_load": false,
"exclude": [
".*[\\\\/]vendor[\\\\/].*", // vendor-path (used by Composer)
".*\\.phtml$" // files ending with ".phtml"
]
}
After installing the Xdebug Client add the following into your project settings:
Notice that the path_mapping
format is path_mapping: {"guest OS path": "host OS path"}
.
{
"settings":
{
"xdebug":
{
"path_mapping":
{
"/home/vagrant/Projects/project.name/repository": "/home/juan/Projects/project.name/repository"
},
"url": "http://project.name/"
}
}
}
Then log in into your Homestead environment, set your preferred default PHP version, turn on the Xdebug extension and restart the FastCGI service for the changes to take effect.
homestead ssh
php73
xon
sudo service php7.3-fpm restart
Restart Sublime if necessary.