If you’re already running a local server with PHP or similar, you’ll need to use the proxy mode. browser-sync start -server -files "css/*.css" Dynamic sites Browsersync will start a mini-server and provide a URL to view your site. html files, you’ll need to use the server mode. Navigate your terminal window to a project and run the appropriate command: Static sites You’re telling the package manager to download the Browsersync files and install them globally so they’re available to all your projects.Ī basic use is to watch all CSS files in the css directory and update connected browsers if a change occurs. Open a terminal window and run the following command: npm install -g browser-sync The Node.js package manager (npm) is used to install Browsersync from a repository. There are convenient installers for MacOS, Windows and Linux. This release has some more improvements around auto-detection, we’ve also added auto-detection of enabled extensions under the PHP configuration as part of our continuing mission to make using PhpStorm easier (more information comes in future blog posts).Browsersync is a module for Node.js, a platform for fast network applications. When you use this feature, you get the added bonus of automatically configuring PHPUnit and Behat if you’re requiring them as a dependency (or development dependency) in your `composer.json`. To make this happen, PhpStorm needs only to have Composer configured correctly including where to find the Composer executable, and which `composer.json` file to use. We’ve learned that you should be defining your autoloading rules and minimum PHP version in your Composer settings and that PhpStorm also needs you to configure this information to work at its best – so why can’t PhpStorm read the Composer configuration to save you configuring it yourself?Īs of 2017.2 PhpStorm can now read your Composer configuration to automatically configure directories and PHP version for you. The `autoload` files are available to autoload always, whereas the `autoload-dev` files are only autoloadable in your dev environment (which is nice to avoid polluting the autoloader with tests in production).Ĭomposer also allows you to tell it the minimum version of PHP you support and will fail to install if the target system doesn’t run the supported version: Using these Composer directives allows you to use a single autoloader for locating and loading both libraries files pulled in as Composer dependencies and your own code and test. Of course, the most common way of autoloading files in this day is to use the `autoload` and `autoload-dev` keys of your `composer.json` file to setup autoloading for you. Here we can see that we’ve marked `lib/Doctrine/ORM` as a PSR-4 namespace root for the `Doctrine\ORM` and `tests/Doctrine/Tests` as a PSR-4 namespace root for `Doctrine\Tests`.Īdding this information is a little cumbersome and we’ve made attempts before to automate the process using the Detect PSR-0 Namespace Roots action (under the Code menu), but this has never been entirely successful and is getting less useful with the prevalence of the PSR-4 autoloading standard. It’s important when you’re marking folders as either Tests or Sources that you also tell PhpStorm which namespaces those directories contain, and you can do this by clicking on the Package Prefix icon under the directory listing in the right-hand pane: You can learn more about marking directories in the web help article. Resource Root – Contains resources that can be accessed relatively – like images, CSS files or javascript.Sources – Mark as a source of PHP autoloadable classes.Tests – Mark the directory as a source of PHPUnit tests.You can mark directories as sources or tests from the context menu in the project pane, or you can use the Directories section of the Preferences window. Telling PhpStorm where your namespaced files live will help when creating classes and tests (and navigating between them) and refactoring things. You can configure the PHP version you are targeting using the dropdown you’ll find under Preferences | Languages and Frameworks | PHP: Telling PhpStorm which version of PHP you’re targeting allows the inspections that power the IDE to let you know if you’re using things that are deprecated (or not available in your target version), and enables some features that are only available in later versions of PHP like the scalar parameter and return types. When you’re using PhpStorm to develop efficiently, there is a few configuration setting that should be right to make the IDE is as helpful as possible. Configuring PhpStorm correctly is important to get the most out of your IDE, and PhpStorm 2017.2 has made it easier by allowing you to detect some of the settings from your `composer.json` file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |