This blog post covers the installation of Sublime Text 3 for PHP Development on Linux. Since Sublime Text 3 is still in beta, some things are prone to break.
The installation of Sublime Text 3 is pretty straight forward, just run:
curl -L git.io/sublimetext | sh
This will install it in
/opt/sublime_text
You can check everything is working by pressing
Ctrl+`
and looking for any errors.
If this does not work and you have erros, you can download it from here. In this case, you will need to install Package Control as well, as it doesn’t come with it by default. You can install it from here.
We need to install PHP Mess Detector and PHP Code Sniffer next. I’ve run this under Fedora, but for Ubuntu / Debian or other Linux flavors, it should be pretty similar:
sudo dnf install php-phpmd-PHP-PMD.noarch php-pear-PHP-CodeSniffer.noarch
We also need to download and install php-cs-fixer. All one needs to do is download it and move it to the bin folder.
curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer sudo chmod a+x php-cs-fixer sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
Next we will have to install the packages so hit
Ctrl+Shift+P
to bring up Package Control. Once there, select Package Control: Install Package, look for Php Cs and hit enter.
Now that it is installed, we need to create a folder for it in the Packages configuration folder so that it may store any configuration changes we make. Please ajust the path depending on your operating system.
mkdir .config/sublime-text-3/Packages/Phpcs
Once its installed we also need to configure it. So go to Preferences -> Package Settings -> Php Code Sniffer -> Settings – default and modify the following lines:
// Execute the sniffer on file save "phpcs_command_on_save": true, "phpcbf_on_save": true, // Path to where you have the phpcbf installed "phpcbf_executable_path": "/usr/bin/phpcbf", // Fix the issues on save "php_cs_fixer_on_save": true, // Path to where you have the php-cs-fixer installed "php_cs_fixer_executable_path": "/usr/local/bin/php-cs-fixer", // Execute phpmd "phpmd_run": true, // Execute the phpmd on file save "phpmd_command_on_save": true, // It seems python/sublime cannot always find the phpmd application // If empty, then use PATH version of phpmd, else use the set value "phpmd_executable_path": "/usr/bin/phpmd",
Depending on your linux version you may need to make adjustments to the paths.
Now for phpunit. To install it simply run
sudo dnf install phpunit
Once that is finished, we need to install the package for Sublime so bring up Package Control, select Package Control: Install Package, and look for
PHPUnitCompletions
And install it.
Thanks it, more stuff in future posts!
One thought on “Setting Up Sublime Text 3 for PHP Development”