Php Linter Phpstorm

Posted : admin On 1/2/2022

PhpStorm integrates with ESLint which brings a wide range of linting rules that can also be extended with plugins. PhpStorm shows warnings and errors reported by ESLint right in the editor, as you type. With ESLint, you can also use JavaScript Standard Style as well as lint your TypeScript code.

Note:- This blog is updated on 13-11-2020.

All set to get your hands unclean with PHP development tools? PHP IDE is the primary tool that you require to get on the go with PHP programming. There are a lot of IDEs accessible in the market, both free and paid, and picking one can be a tricky job.

It is utterly possible to get going ahead with PHP programming tools in a fundamental text editor, like notepad, but healthier is to commence off with a feature rich and absolute PHP IDE such as NetBeans. The set of tools like PHPStorm, VIM, Cloud9, Zend Studio, and Atom are, particularly for professional web development.

The best PHP IDE comes filled with multiple features and functionalities with using PHP programming support. The integrated development environment is a developer’s open space and to improve it you need to invest efforts and time upfront to choose the PHP web development tools that most excellently fits your project requirements.

  1. An advanced, custom PHP code checker that searches your code for common, hard to find typos and mistakes; includes a syntax check.
  2. Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community-created VS Code extensions. VS Code uses the official PHP linter (php -l) for PHP language diagnostics. This allows VS Code to stay current with PHP linter.
  3. PHPStorm PHPStorm is the best IDE for PHP developer and comes packed with the freshest set of features that facilitate swift web development. It is developed and promoted by a company named JetBrains.
  4. Is there any other way to lint LESS files in a PhpStorm project? For example, I need all properties to be sorted alphabetically within a class definition. Less phpstorm linter. Improve this question. Follow edited Nov 22 '16 at 15:36. Asked Nov 22 '16 at 10:05.

Which one you must go for? This query is for you and the choice depends on what you necessitate, like, and can have the required funds. It is not an awful idea to try some prior to closing on one of them. Let us give you a few statistics concerning PHP which will stimulate you the most. As per a survey carried out by Inc, PHP is a 7th well-liked programming language across the world and as per GoCertify, it is the 5th most extensively utilized programming language in all over India.

There is a lot of PHP editors available that are maintained on Windows, Linux, and Mac and are obtainable for free download. If you are a learner web developer, setting up to learn PHP, my advice is to go in advance with freely on hand PHP coding software like NetBeans, VIM, Atom or Eclipse PDT.

Enterprises developers can also get the job done with these free IDEs. However, there are commercial and business-related IDEs accessible. They are more superior and are backed by enterprises, supporting the newest set of functionalities as well as advanced features. The best IDEs in 2021 for PHP Programming comprise of PHPStorm, Zend Studio, Sublime Text, Nusphere, PHP Designer, PHPED and Cloud 9, to name some.

  1. PHPStorm

    PHPStorm is the best IDE for PHP developer and comes packed with the freshest set of features that facilitate swift web development. It is developed and promoted by a company named JetBrains. It is in the midst of the most accepted companies in developer tools market and is making PHP coding software simpler and pleasant for developers for preceding 15 to 16 years.

    PHPStorm works well with key frameworks like Symfony, Zend Framework, Yii, CakePHP and Laravel. It even supports chief Content Management Systems (CMS) such as Drupal, Magento, and WordPress.

    Any web development project is not absolute without front-end technologies and that is where PHPStorm works the best. It enables live editing of front-end technologies including CSS, Sass, HTML5, CoffeeScript, TypeScript, JavaScript, Stylus, Less and others. It enables code refactoring, debugging and unit testing.

    When it comes to best tools for PHP developers, it provides access and integration with sturdy version control systems, different databases, PHP MySQL development tool, vagrant, composer, remote deployment, rest client and command line tools. From debugging viewpoint, it works with Zend Debugger and Xdebug, both remotely and locally.

    PHPStorm is an enterprise grade IDE, which comes with a license price and largely targets specialized developers. It, on the other hand, is offered, free of cost to students, teachers and to enable open source projects.

    The reputation of PHPStorm can be gauged from the reality that big brands like Yahoo, Expedia, Cisco, Wikipedia, and Salesforce have bought PHPStorm IDE licenses.

  2. Eclipse PDT

    Eclipse PDT is a highly used Open Source PHP Development Tools is another open source preference without directly costing you. Eclipse has a massive community of developers working on all sorts of plugins, requisite to authorize Eclipse with features that any other best PHP IDE such as Storms PHP, NetBeans, and Zend studio has to provide.

    It is a slightly tricky task in the commencement to get underway with Eclipse as contrasted to other business-related IDEs but its use is worth the money it saves for you. It saves on licenses which are the biggest gain if you ask for an evaluation amid Eclipse PDT and PHPStorm or Zend Studio. If you are an old-time Eclipse follower, you will feel easy to deal with Eclipse PDT.

    Some people say that Eclipse is sluggish and let me be frank; it is time-consuming when you deal with system configuration while other business-related products relatively perform superior. However, the fundamental laptop configuration these days it is of high-quality to run Eclipse swift enough to not let you perceive any lags.

    Some of the essential features comprise syntax highlighting, code formatting, code assist, refactoring, code navigation, code templates, PHP debugging, syntax validation and eclipse ecosystem that possess a vast community which is quite supportive.

    To start off with, you can download Eclipse package for PHP developers which comes fully to a capacity of PHP language support, Git client, XML Editor, and Mylyn.

  3. NetBeans

    NetBeans is the PHP IDE for plenty; it is attributed rich, free and enables manifold languages, counting English, Russian, Japanese, Brazilian, Portuguese, and basic Chinese. The free version of NetBeans dates back to 2010 when it was originally prepared open source by Sun Microsystems, getting hold by Oracle afterward.

    Ever since its release, NetBeans boosts one of the largest communities of developers operational on an open source integrated development environment being downloaded 18+ million times.

    Gone are the days when this tool was sluggish and was known only for development in Java, the existing stable release of NetBeans is lightweight, much quicker and supports the whole thing in PHP. It has the best support resources for all the rage PHP frameworks like Zend, Smarty Doctrine, and Symfony2. It even supports Laravel through Laravel-ide-helper and enables support for frameworks such as Yii, FuelPHP, CakePHP and WordPress CMS.

    Some of the essential features that keep NetBeans on a peak of the list comprise code generation tools like getter setter generation, smart code completion, code templates, quick fixes, hints and refactoring. Other fundamental features supported include try/catch code completion, code folding, and formatting as well as rectangular selection.

    When it comes to debugging, you can moreover use a command line or xDebug together locally and remotely. NetBeans PHP Editor supports web development taking into account JavaScript, HTML, and CSS. All these features simply make NetBeans as the paramount open source PHP IDE.

    which PHP IDE comes with SSH support and which PHP IDE has Git support? Yes, NetBeans, you guessed it right.

  4. Sublime Text 3

    It is an accepted and a competing tool for the most sturdy text PHP editors. It is lightweight with required feature and is supported on OSX, Windows as well as Linux. The Sublime text editor is put up to gain its powers through different plugins and packages.

    There are a lot of PHP packages accessible out there in the market that assists in transforming this smart editor into a graceful Sublime PHP IDE. Some of the most helpful and noteworthy packages for this purpose consist of package control, xDebug client – CodeBug, Sublime PHP companion, Simple PHPUnit, PHPCS, CodIntel, and PHPDoc.

    Once you group sublime text 3 as a PHP IDE with aid of add-on packages, you get classiness of sublime text as well as the sturdiness of PHP at one place, for an utter easiness of PHP development.

  5. NuSphere

    It is another company that is keen on developing best tools of PHP products to step up web development experience and PHPED is the IDE they have to propose.

    It supports the most recent release of PHP Editor that supports PHP 7 and many other new as well as old PHP frameworks which includes Laravel, Yii and Symfony to include few along with the Content management systems (CMSs) like WordPress and Joomla. The added feature with the most up-to-date release is the capability to run unit tests for mutually local and remote projects.

    In summing up, NuSphere PHPED IDE is a packed stack web development tool that comes full with support for JavaScript debugging, CSS pre-processing with LESS pre-processor, HTML5 and rest of everything in PHP.

    Having supposed that, I would rate Zend and PHPStorm superior to NuSphere in terms of style, the end to end customer support, enhanced documentation and release execution in the required commercial space.

  6. Zend Studio

    Zend Studio is amongst the top commercial PHP IDE from the development house of the organization named Zend and targets proficient web developers.

    Zend as a company provides all the things covering PHP functionalities and has a huge number of clientele utilizing one or other of its products that assists PHP development with a supreme breeze. Some of its top clients incorporate companies like DHL, BNP Paribas Credit Suisse, and Agilent Technologies.

    Zend Studio is enabled on Windows, OS X, and Linux and works with most recent PHP versions counting PHP 7. Zend Studio comes with an instinctive user interface and offers most of the up to date features and tools that lend a hand to speed up PHP and web development with multiple purposes. Some of the essential features of Zend Studio comprise

    • Swifter performance in indexing, validation and searching PHP code
    • Debugging with Xdebug, Zend Debugger, and integration with Z-Ray
    • Hold up the Eclipse plugins ecosystem, Docker and Git Flow support
    • Sharp code editor which supports PHP, JavaScript, CSS, and HTML
    • Deployment sustenance which included cloud support for Amazon AWS and Microsoft Azure
    • Backing for PHP 7 express migration and flawless integration with Zend server

    A powerful feature of Zend is its support for mobile application development on the peak of live PHP apps and server system backend. This offers a good initiation in development when it comes to harmonizing present websites and web applications with mobile-based apps.

  7. Atom

    Atom is an up to date text editor built by GitHub folks and accessible free of cost underneath MIT license. Atom has an ecosystem of its own with the vast community at the back of it and tons of plugins and packages on hand to expand its functionality.

    Atom is truly flexible which means you can turn Atom into your required PHP online editor since it is scalable and extremely customizable. In addition, it is an accurate cross-platform alternative with support for Windows, Red Hat Linux, OS X, Debian Linux and Fedora 22+.

    How to twirl Atom into PHP IDE Free?

    When it comes to PHP, there are numerous packages presented that convert Atom editor into an entirely loaded IDE for PHP which is not only free of cost but very effective than many other commercial PHP IDEs.

    The packages you call for to turn atom editor into a totally functional free PHP IDE comprise php-cs-fixer, hyperclick-php, php-integrator-base, linter-php and atom-autocomplete-php.

  8. Komodo

    It is Developed by ActiveState in the year 2000, Komodo IDE is one of the best PHP MySQL development and functional tools. Most of the functionality of Komodo is innate from the Python interpreter.

    It utilizes Mozilla and Scintilla as its foundation for the reason that they share much functionality, features and support the alike languages. Due to its numerous extensions and pipe feature, Komodo has turned to be an enormous success.

    Features:-

    • Provision of Split View and Multi-Window
    • Swift Bookmarking
    • Smart Language Detection
    • Document Object Model Viewer
    • Sustain for Git and Remote File Access
  9. Aptana Studio

    The Aptana Studio built by Aptana Inc. in the year 2014 is one of the finest open source PHP development tool. It is simple to download from the web and accessible to all at free of cost. It is obtainable as a standalone on Windows, Mac and Linux OS.

    Features:-

    • Comes with Syntax Error Annotations
    • Has built-in PHP Server
    • Supports DOM and CSS
    • Code Formatting and Auto Indexing
    • Supports PHP Debugger
  10. Cloud 9

    Cloud9 comes pre-packaged with necessary tools for all the rage programming languages, together with JavaScript, Python, and PHP, so you don’t require installing files for your development machine to commence new projects. In view of the fact that your Cloud9 IDE is cloud-based, you can execute your projects from your home or office or anywhere utilizing an internet-connected machine.

    The platform offers a flawless experience for developing serverless applications empowering you to straightforwardly define resources, debug, and switch amid local and remote execution of serverless applications. With Cloud9, you can swiftly share your development environment with your team, facilitating you to pair program and monitor every other’s inputs on a real-time basis.

    Features:-

    • Code just with a browser
    • Code mutually in real time
    • Build serverless applications with effortlessness
    • Initiate novel projects swiftly
    • Direct using a terminal access to AWS
  11. Codelobster

    Codelobster IDE modernizes and simplifies the PHP development procedures. You don’t require keeping in mind the names of functions, arguments, tags, and attributes. The platform has enabled all these for you with auto complete functions intended for PHP, HTML, JavaScript, and CSS.

    An internal free PHP Debugger facilitates you to validate the code on a local basis. It automatically detects your existing server settings and configures related files to let you utilize the debugger.

    Codelobster IDE has the following features and capabilities to work with Magento:

    • Higher capacity to build projects automatedly installing Magento platform
    • Autocomplete for Magento methodologies
    • Tooltips for Magento methodologies, Context, and Dynamic help
    • Codelobster IDE backs Windows, Mac OS, Linux, WordPress, Ubuntu, Mint, Fedora, etc. and has exceptional plug-ins for working smoothly with Joomla, Drupal, Twig, JQuery, Symfony, CodeIgniter, Node.js, BackboneJS, EmberJS, CakePHP, VueJS, Laravel, AngularJS, Phalcon, Magento, and Yii.

    So, Which PHP code editor can I choose? Let’s explore some more options.

  12. Novi HTML Visual Editor

    Novi HTML visual editor, the technical side of the HTML editor, was enormously user-oriented. In 2016, Elementor for WordPress was the only proficient drag & drop editor that offered WYSIWYG abilities. So, people required something such as that for HTML-based online projects.

    Firstly, Novi facilitated non-technical professionals to design their websites without difficulty. Secondly, the builder turned useful to multiple web designers as well as developers. This visual HTML editor enabled all over the world to further the working process effortlessly.

    The fundamental actions and features users were able to execute with Novi:

    • Craft clean, structured site layouts with a code-free approach
    • Enabled drag and drop technology
    • Design pages of utilizing ready-made content modules
    • Generate visitor-friendly web portal navigation
    • Customize UI and UX elements
    • Use of ready-made content blocks
    • Set-up elements swiftly
    • Handling media library
    • Change color schemes, gradients, and images
    • Enabling CSS, HTML, and JS code
    • Facilitating contact forms, popups, and maps
    • Applying visual effects, carousels, countdown timers, and sliders

    So, which IDEs are the best for PHP development? Let’s explore some more alternatives.

  13. Brackets

    Brackets which is an advanced and modern text editor, makes it simple to design in the browser. With straightforward visual tools and pre-processor backing, it is quite tailor-made for web designers and front-end developers.

    Here are some of the functionalities and features of Brackets

    • Inline Editors
    • Instead of jumping amid file tabs, Brackets enables you to open a window right into the code. Brackets facilitate you with all the CSS selectors with that ID in an inline window so you can implement code side-by-side without any popups’ involvement.

    • Live Preview
    • You can enable a real-time connection right to your browser. Make modifications to CSS and HTML, and you will instantaneously see those alterations on screen. Also, view where your CSS selector is being used in the browser by cleanly putting your cursor on it. It is the sturdiness of a code editor with the handiness of in-browser dev tools.

    • Pre-processor Support
    • With Brackets, you can utilize Quick Edit as well as Live Highlight with LESS and SCSS files, which will turn working with them more straightforward than ever.

  14. Dreamweaver

    Adobe Dreamweaver is a leading and professional web development software package. It is a multi-faceted product fitting for everything right from straightforward page design to development of dynamic pages supported or written with PHP, ColdFusion, XML, XSLT, ASP, CSS, and JavaScript.

    Some of the features of Dreamweaver

    • Integrated CMS Support
    • Dreamweaver enables to test most CMS’s, including Drupal, WordPress, and Joomla. This feature comes with live view navigation that facilitates viewing the webpage in action for simple editing. For implementing dynamic pages it helps you access all page associated files.

    • Smart Coding Assistance
    • As beginners, you can benefit from the JavaScript, HTML, and Ajax code hints that Dreamweaver offers. The code hinting includes Spry, Prototype, jQuery, and PHP methods.

    • CSS Support
    • Dreamweaver enables us to showcase the CSS box model without requiring or knowing how to code CSS manually.

  15. Notepad++

    Notepad++ is an absolutely free source code editor and Notepad substitute that backs multiple languages. It runs in the MS Windows environment and is governed by GPL License.

    The features of Notepad++ include

    • Autosave
    • Finding and replacing strings of text using expressions
    • Enable Line bookmarking and Guided indentation
    • Allows macros and simultaneous editing
    • Facilitate split screen editing along with synchronized scrolling
    • Helps with line operations, sorting, and case conversion
    • Assists with the removal of redundant whitespace
    • Lends a hand with tabbed document interface

Conclusion:-

PHP is the most well-liked and all-inclusive programming language for web development and there are loads of PHP IDEs obtainable which are further advancing with time. Most of the PHP development tools covered in this blog come with diverse flavors but the universal objective is bringing swiftness into web development with convenient and scalable code.

Take a closer look, list down some of your important requirements and choose the best PHP web development tools that most excellently fit your needs.

If you have any question or planning to develop a PHP web application for your business then you can contact us. We have experienced team of PHP developers who are able to full fill your requirements.

A lot of folks in the PHP community have been checking out PHPStorm lately, including myself and most of the developers I work with. We love the code intelligence we get from PHPStorm, but still miss the speed, quick boot-up, and convenience of Sublime Text.

Before I blindly assume PHPStorm is the only way to go, I wanted to see: Can I bring the things a PHP-focused IDE provides PHP developers back to Sublime Text and get the best of both worlds?

Let's start with a quick list of ways that PHPStorm really sets itself apart for me. Please note: There are a million other features that PHPStorm uniquely offers, but to be honest, it's the tiny little conveniences that I've seen provide the biggest boost in efficiency.

Also note: This is Sublime Text 3 we're talking about.

My Must-Haves From PHPStorm

Without most of these wonderful PHP-focused features, it'll be hard to recommend using something other than PHPStorm, even if it's slower and costlier and uses more memory. So. Can we reproduce them in Sublime Text?

  • Auto-use (import) of classes
  • Class FQCN inline completion
  • Easily navigate to a symbol's definition
  • Easy constructor injection
  • Highlight unused imports
  • Git gutters
  • Code sniffing/PSR-2 validation
  • Code Completion: PHP
  • Code Completion: project code

Package Control

Before we talk about anything else, you at least need to know how to install packages in Sublime Text.

If you haven't yet, Go install Package Control now.

Unless otherwise specified, every package after this should be installed using Package Control.

Sublime PHP Companion

The most significantly PHP-focused package for Sublime Text is called Sublime PHP Companion.

Like most packages, it contains a series of actions you can perform. ~~They're mapped to certain keys by default, but you can always re-map them.~~ Update: there is no keymapping by default anymore. Learn more about how to set up PHPCompanion keymapping here.

  • find_use (F10) - When your cursor is over a class name, this command makes it simple to use (import) that class.
  • expand_fqcn (F9) - Same as find_use but instead of expanding the class in the import block, it expands its FQCN inline.
  • import_namespace (F8) - Adds the namespace for the current file based on the file's path.
  • goto_definition_scope (shift+F12) - Same as Sublime Text's native goto_definition (described below), but scoped in a PHP-aware manner.

The package isn't perfect, and it is clearly not as bright as PHPStorm is when it comes to detecting namespaces and parsing some weird edge cases. But for day-to-day work, this is a huge boost in the PHP-code-knowledge area.

AllAutocomplete

Sublime PHP Companion doesn't sniff your classes and give you autocompletion, sadly, but SublimeAllAutocomplete does register the names of all symbols (functions, classes, etc.) in any files you have open in other tabs and add those to the autocomplete register.

This isn't quite the same as full userland-code-sensitive autocompletion, but it helps a lot.

Cmd-click for function definition

Sublime PHP Companion makes it easy to right click on functions and go to their definitions, but this shortcut brings back PHPStorm's CMD-click-to-definition. FYI, in Sublime Text CMD (or windows' ctrl key or whatever it is on other systems) is called 'Super'.

First, create a user mousemap file. If you don't have one, go here:

LinuxCreate Default (Linux).sublime-mousemap in ~/.config/sublime-text-3/Packages/User

MacCreate Default (OSX).sublime-mousemap in ~/Library/Application Support/Sublime Text 3/Packages/User

WindowsCreate Default (Windows).sublime-mousemap in %appdata%Sublime Text 3PackagesUser

Next, place this in the file:

You just taught Sublime Text this: 'when I hold ctrl and click button one, fire the goto_definition command.' Done! (original source)

Note: I originally wanted to suggest using the super modifier, so it would be just like PHPStorm; however, that would override Sublime Text's 'hold super and click to get multiple cursors' behavior, so I didn't.

Code sniffing and PHP_CodeSniffer

Sublime PHPCS

There's a package named Sublime PHPCS that brings PHP_CodeSniffer, PHP's linter, PHP Mess Detector, and Scheck (?) to bear on your code.

You can tweak all sorts of settings, but you're primarily either going to run it every time you save your file (good, but can get annoying), or every time you trigger it from the command palette (press super-shift-p and then type until you get 'PHP Code Sniffer: Sniff this file') or keyboard shortcut (ctrl-super-shift-s by default).

You'll get gutter highlights and a list up top of all of the places your code doesn't satisfy the linter.

Note that this and any other packages that rely on code sniffing and linting will be requiring command line applications installed, so be sure to visit their sites and read their directions.

PHP_CodeSniffer Sublime Text 2/3 Plugin

Interestingly, there's a relatively un-noticed plugin doing the same thing (but for PHPCS only) that's written by the same group that wrote PHP CodeSniffer, so it might be worth checking out as well; it's called PHP_CodeSniffer Sublime Text 2/3 Plugin (creative, I know.)

I've never used this one, though, so proceed with caution.

Mike Francis PHP CS Fixer Build Script

Mike Francis also shared a custom build script he wrote that runs PHP-CS-Fixer on your code whenever you trigger it. That means it'll actually enforce PSR-2 (or whatever other PHP-CS-Fixer standard you pass it) on your code for you.

Taylor Otwell actually shared this same script with me, but he didn't write it up as nicely as Mike did. :) He did, however, mention that you might want to set this preference: 'show_panel_on_build': false, This'll keep it from popping out the command panel with your results every time, which can get very irritating very quickly.

SublimeLinter

SublimeLinter PHP (and its required dependency, SublimeLinter) rely on PHP's built-in linter (just like the Sublime PHPCS plugin above). This is a simpler version that only runs the linter, nothing else.

Php Lint Phpstorm

DocBlockr

If you're the type to use PHPStorm, there's a greater chance that you're the type to write Doc blocks. (Just sayin').

DocBlockr makes it simple to create new doc blocks, but more importantly, if you create a doc block just above a defined function, it will extract that function's parameter information and pre-fill it in your doc block. Boom.

Git helpers

Sublime Text Git

Are you the type that hates switching from your IDE to your terminal/Git client? Sublime Text Git provides access to many Git commands directly from the Sublime Text command palette.

GitGutter

GitGutter shows you diff information regarding each line's status--has it been modified, inserted, or deleted?

This is not nearly as powerful as PHPStorm's Git gutters, but it's a step in the right direction.

Syntax Highlighting

  • PHP-Twig for Twig
  • Laravel Blade Highlighter for Laravel Blade
  • Bracket Highlighting - shows the start and end bracket in the gutter for the block your cursor is currently in

PHPUnit Build

There's a great plugin that makes it super easy to run PHPUnit from the command palette or a keyboard shortcut: SimplePHPUnit

Just like the name implies, you install the package and you're up and running.

CodeIntel

CodeIntel is supposed to provide Sublime Text intelligence about the language you're working in. It should provide autocompletion, easy jump-to-definition, and information about the function you're currently working in.

Why do I keep saying 'should' and 'supposed to'? Because I have yet to meet a PHP developer who can get CodeIntel up and running consistently and predictably. Have you? Hit me up.

Other Plugins

Php Linter Intellij

When I asked around on Twitter, plenty of folks shared plugins. Since I don't use these, I can only share them vaguely, but I'm sure they're all worth a quick check.

Linter
  • ApplySyntax extends Sublime Text's ability to determine which syntax to apply to your current file
  • DashDoc makes it easy for Mac users with the Dash application to look up any word in Dash
  • Function Name Display adds information to the status bar about the current file, class, and function/method name
  • phpfmt looks like an alternative to PHP CS Fixer
  • CodeComplice is code intel, but newer—maybe this is the solution?!
  • EditorConfig is a standard to share particular editor configuration patterns for each project. This plugin lets you import and use them in Sublime Text. (learn more about the EditorConfig format)
  • SublimePrettyJSON is great for quickly formatting JSON
  • CaseConversion makes it simple to convert between snake_case and camelCase and PascalCase and split and join words and everything else.

CodeBug for Xdebug

Do you miss the Xdebug integration in PHPStorm? Check out Codebug, a standalone xdebug client.

A Few General Sublime Text Tips

This post is not an introduction to all things Sublime Text, but I do want to cover a few important pieces here.

Finding files with 'Goto Anything' (cmd-p)

If you press super-P you'll get the wildly powerful Goto Anything palette, which allows you to easily find files, but you can go a bit further: if you find your file (e.g. by typing Handler.php), you can also trigger opening it at a certain line (Handler.php:35) or at a certain symbol ([email protected]).

Finding commands with the Command Palette (cmd-shift-p)

While the Goto Anything palette lets you search for files in your project, the Command Palette allows you to search for commands.

This means that any command that Sublime Text lets you perform (run builds, rename files, etc.), but also those from third-party packages (Sniff this file, etc.) can be run purely from the keyboard, even if you don't know (or have) the keyboard shortcut.

Finding symbols with 'Goto Symbols' (cmd-r)

If you press super-R you'll get the Goto Symbol palette, which will navigate to any symbol in your current file.

Symbols are things like classes, methods, or functions.

Multiple cursors

Many editors have added multiple cursors, but Sublime Text still does it the best.

If you've never tried it, go learn about it somewhere, but here's a quick intro:

Open up a file. Hold 'super' (cmd on Mac) and click several places around the file. Now start typing. BOOM.

Another great trick: Place your cursor on a common word (for example, a variable name). Now press Super-D a few times. You now have several instances of that variable selected and you can manipulate them all at once.

Or, select five lines and press Super-shift-l. Check it.

There's a lot more you can do with this if you get creative.

Fuzzy matching

Did you know that when you're using any of the command palettes in Sublime Text, you don't have to finish one word?

In most editors (like PHPStorm), if you wanted to find a file named resources/views/conferences/edit.blade.php, you could type resources/views/conferences/edit.blade.php or conferences/edit.blade.php, but in Sublime Text all you would need is something like resvieconedblp. Just type enough that the order of letters you're typing could only exist in the string you're looking for, and you'll be good to go. Skip a letter here, skip a slash there--no problem.

Miscellany

There's a lot more to learn about how Sublime Text works, and a lot of tools and courses available to you. This is not a comprehensive resource for everything that's great about Sublime; those guides have already been written.

If you want to learn more about Sublime Text, there are two excellent resources I'd consider checking out.

  • Sublime Text Power User is a book and video series by my friend Wes Bos that teaches you everything you need to use Sublime Text like a boss. It's the easiest way for someone new to Sublime Text to get up and running quickly. Also, I reached out to Wes and he gave me a GEEK coupon to get you $10 off (disclaimer: it helps me out, too.)
  • ShortcutFoo is a great resource for learning keyboard shortcuts for any environment. They've got programs for everything from Vim to Sublime Text to Photoshop to Excel.

The Verdict

Let's take a look at our list and see what we've handled:

  • ~~Class FQCN inline completion~~ (Sublime PHP Companion)
  • ~~Easily navigate to a symbol's definition~~ (Sublime PHP Companion)
  • ~~Navigate to a symbol's definition~~ (Sublime PHP Companion)
  • Easy constructor injection (Macro?)
  • ~~Highlight unused imports~~ (SublimeLinter)
  • ~~Git gutters~~ (GitGutter)
  • ~~Code sniffing/PSR-2 validation~~ (SublimePHPCS etc.)
  • Code Completion: PHP
  • Code Completion: project code

Not bad, actually. Let's talk about what's missing:

  • Construction injection (e.g. simplifying injecting a property into the constructer as a property, setting it in the constructor, and defining the class property) is something I think can be solved with a clever macro—but I haven't seen that clever macro yet.
  • CodeIntel purports to offer PHP code completion, so it's just a matter of getting that working. But I don't think (correct me if I'm wrong) anything in the Sublime Text world claims to sniff the definitions of your code and then provide autocompletion and parameter suggestion. So that's a big shortcoming for sure. Note, however: AllAutocomplete definitely relieves this pain a little.

What's my verdict? As always, it depends. I think it'll depend some on the project, some on the developer, and some on whether or not I can find solutions to some of the issues above. But I'm definitely leaning on Sublime Text a lot more than I was six months ago—it's just so darn fast.

Postscript

Are there any Sublime Text tips for PHP developers that I missed? Let me know on Twitter.

Are there any PHPStorm features that I didn't cover here that you think are vital to every developer's toolkit? Let me know that too.

Also: I couldn't've written this without Adam Wathan, Taylor Otwell, Jeffrey Way, and many, many other friends on Twitter.

Tags: sublime textphp