Tweet
Share
Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

Atom, Recommended packages for php development

atom for php image

Here are some recommended packages for the PHP development environment in the text editor Atom.

There are two main ways to do this: "using an IDE" and "using a linter".

This is written by a Japanese who can't speak English with the help of translation application. Sorry if it's not good.

Recommended packages for PHP development in the Atom editor

This is a package of PHP development environment used for web development. atom program development can be divided into two main categories.

  • Use an IDE (Integrated Development Environment)
  • Using linter and other packages

Regardless of which one you use, there is a minimum package required regardless of the programming language. Install them first.

Use an IDE (Integrated Development Environment)

First, install the packages used in the IDE, which I wrote about in "Recommended packages for all genres".

Again, you need atom-ide-ui. And there is only one IDE package needed for PHP.

ide-php

https://github.com/atom/ide-php

ide-php is a PHP pack for atom-ide-ui. php language packs are distributed by atom officially.

ide-php requires the PHP Language Server, which can be installed in your PHP environment using composer.

composer global require felixfbecker/language-server --dev
  • I installed it in PHP itself with global because installing it in the project would mean installing it many times.
  • I added --dev because I use it only in the development environment.

The installation of PHP Language Server may fail.

install error
composer global require felixfbecker/language-server --dev
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - felixfbecker/language-server v5.4.6 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.5 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.4 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.3 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.2 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.1 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - felixfbecker/language-server v5.4.0 requires jetbrains/phpstorm-stubs dev-master -> satisfiable by jetbrains/phpstorm-stubs[dev-master] but these conflict with your requirements or minimum-stability.
    - Installation request for felixfbecker/language-server ^5.4 -> satisfiable by felixfbecker/language-server[v5.4.0, v5.4.1, v5.4.2, v5.4.3, v5.4.4, v5.4.5, v5.4.6].


Installation failed, reverting ./composer.json to its original content.

This is because the composer refuses to install development plug-ins by default.

Add the configuration to the composer.json file.

"minimum-stability": "dev",

Force development plugins to be stable.

Example of compsoer.json
{
    "minimum-stability": "dev",
    "require-dev": {
    },
    "require": {
    }
}

https://github.com/felixfbecker/php-language-server/issues/686

Sometimes ide-php does not display outlines correctly. In that case, use symbols-tree-view instead.

That's it for the php package in the IDE.

Next is the php package using linter, which requires more packages to be installed than the IDE because it requires separate packages.

All functions overlap with the IDE. If you use the IDE, you don't need it.

Use linter as the main tool

First of all, install the package that is used for the non-IDE version, as described in "Recommended packages for all genres".

The main focus is on linter. In addition to that, here are the packages required for PHP.

linter-php

https://atom.io/packages/linter-php

This is an extension package of linter for php. It performs static code checking and should be installed whenever you use linter for php development.

linter-phpcs

https://atom.io/packages/linter-phpcs

One of the most common tools for checking php coding conventions is phpcs (Php Code Sniffer).

This is the linter extension package, which checks the coding conventions up to PSR-2.

PSR (PHP Standards Recommendations)

https://www.php-fig.org/psr/

A standardization effort for PHP coding, developed by PHP-FIG.

PHP-FIG (PHP Framework Interop Group)

http://www.php-fig.org/

PHP Framework Interoperability Group, an organization where PHP projects get together to discuss and coordinate the compatibility of each other's products.

Many famous projects are participating.

This package requires phpcs to be installed in the php runtime environment. To install it, use composer.

Install phpcs
composer [global] require "squizlabs/php_codesniffer=*"

"=*" means the latest version.

Because of the flexibility of php coding, it is easy for a program to become unmaintainable.

This is not as efficient as it could be. It is always better to use something related to these coding conventions.

Debugger

debug   

To check the operation of a program by running it little by little. The tool used to do this is called a debugger.

The debugger can do the following.

  • Execute one line at a time
  • Execute step by step (specific part).

The program can be paused and restarted repeatedly to check the status of variables, constants, and other values.

and so on.

php-debug

https://atom.io/packages/php-debug

There is a PHP debugger, Xdebug.

https://xdebug.org

There is a debugger package in atom that uses xdebug, and you can use either the IDE or any other package you choose.

There is no debugger for PHP in the IDE at the moment, so use php-debug.

Of course, php-debug requires Xdebug to be installed in the php environment.

Installation and configuration is a bit tedious, so I'll save it for another time.

I'm not using xdebug. Because of this hassle.

Summary

If you use PHP, you will need HTML, CSS, and JavaScript as well.

The Atom editor comes with a standard HTML, CSS, and JavaScript environment of some level.

With the PHP environment in place, web development can be done smoothly.

However, if you use an IDE, you will need to create an environment for HTML, CSS, and javaScript in the IDE.

In this article, I have only introduced the minimum necessary packages.

If you install too many packages, Atom becomes slow and useless. Also, there are many useful packages. Be careful not to install too many.

One more thing: Atom has a number of packages with similar functionality. Be sure to choose one of these packages to install.

It is easier to set the PATH variable for the php command since it can be used without messing with the initial settings of the atom package.

Leave a Reply

*