Modern editor-independent development environment for PHP

公開日:

Download PDF

スライドテキスト

Page 1

エディタ中立なPHP開発環境の現在

Modern editor-independent
development

公開版

environment for PHP

2018-11-23 Akiba Tokyo, Japan

VimConf 2018

#vimconf

Page 2

日本語でおk

筆者の英語は残念なので

発表済みの日本語資料を

先に読むことをおすすめ

Page 3

aka @tadsan

Who am I...?

Kenta Usami

(うさみけんた, @zonuexe)

Language hobbyist, I love Lisp.
Web programmer @pixiv FounderofEmacs-PHP

https://github.com/emacs-php

Page 4

My favorite text editors

Maruo Editor (秀丸)

Mery

Page 5

I usually use Emacs

That's because it's a Lisp
machine that is easy for me to
hack.
There are reasons for each person to choose an editor.
I am a professional programmer,
so I would like to raise development efficiency.

Page 6

First of all...

Page 7

We hate

“Religious War”
宗教戦争

Page 8

Code of Conduct

Page 9

Windows

vs

UNIX

Page 10

Tab

vs

Space

Page 11

Statically typed

vs

Dynamic typing

Page 12

...and

Page 13

Emacs

vs

vi

Page 14

No

It was a joke?

It violates professionalism.

!

Page 15

おk?

Even outside
the conference.
Is that okay?

Page 16

リスペクト

Text editor and Plugin
developers and power users
respect each other and
incorporate the trends of
other text editors.

Page 17

Rainbow Brackets

Page 18

ElePHPant

Page 19

<?php

What's PHP?

It is a kind of Web platform.

Small sites, many CMS, large scale SNS are built with PHP.

It is also a general purpose
programming language.

Page 20

手続き?

PHP as a Language

PHP is procedural and it has
object-oriented feature.

Weak typing and dynamic type-
checking.

PHP is relatively suitable for
static analysis in dynamic langs.

Page 21

知らんけど

“We have things like protected properties.
We have abstract methods. We have all
this stuff that your computer science

teacher told you you should be using.
I don't care about this crap at all.”

–Rasmus Lerdorf
https://en.wikiquote.org/wiki/Rasmus_Lerdorf

Page 22

なんでもできる

Abstract class, Trait, Interface,
Generator, Iterator, Closure, Dynamic
function call, Anonymous class, eval, Type declaration, Associative array (Hash table), Reflection API, Self- documentation, Standard I/O, REPL,
Lazy class loading, etc...

Page 23

ばらばら

PHP coding styles

PHP can be run on cheap
hosting servers.

PHP as a HTML template,

PHP as a CGI script,

PHP as a OOP language...

Various people share PHP.

Page 24

くぁwせdrftgy

PHP needs IDE?

In the early days of my career,
there was no one around me
developing with IDE.

However, the scale of our code was huge and it was obvious that
tool assistance is necessary.

Page 25

ふじこlp;@

PHP with text editor

The usual way to code PHP with a
text editor is tag jump.

But project has multiple methods

with the same name in OOP.

There is no smart input
completion.

Page 26

むりぽ

Refactoring...?

The important thing is sed and a
visual check.

Must allow the possibility of a
run-time error due to
refactoring.

Page 27

Photoshop

PhpStorm

Page 28

つよい

JetBrains IDE

PhpStorm is an IDE derived from
IntelliJ IDEA (Java IDE).

JetBrains' IDE is good at static
analysis and refactoring.

The PHP static analysis features
of PhpStorm is practical.

Page 29

解析できるぞ

Static Analysis

Static analysis is required for
error detection of code path not
executed in test.

PhpStorm can check mistakes with high accuracy if conditions for specifying types are available.

Page 30

ミスがわかる

Coding on PhpStorm

Page 31

スマート

Coding on PhpStorm

Typed

Page 32

わかりやすい

Coding on PhpStorm

Popup
signature

Page 33

Awesome!

PhpStorm

Page 34

But, do we have to purchase PhpStorm
to write PHP?

Page 35

No, No.

Page 36

Since we are developers,
we can create FREE
implementations other
than PhpStorm.

Page 37

クォリティタカス

PHP QA Projects

Page 38

Several PHP static analyzer projects
are active

Page 39

Phan
PHPStan Phpactor

Page 40

鬼強い

Phan

https://github.com/phan/phan

Static analyzer

Slow, but it inspects the entire
project precisely

It's included LSP Server

Page 41

鬼速い

PHPStan

https://github.com/phpstan/phpstan

Dynamic and Static hybrid

Very fast and accurate

Specific RPC and LSP

Page 42

互換性

PSR-5 (PHPDoc)

PHP Standard Recommendation(Draft)

PHPDoc is the de facto standard for
writing type definitions in
DocComment.

They are working on the standard specification of that tag and type
definition

Page 43

鬼速い

Phpactor

http://phpactor.github.io/phpactor/

Phpactor provide code jump,
completion, refactoring

This is under development and is now inferior to PhpStorm, but it
is promising in the future.

Page 44

各位仲良く

Editor-independent
Movements

Page 45

スマート

LSP

Language Server Protocol

https://microsoft.github.io/language-server-protocol/

A Language Server is meant to provide
the language-specific smarts and
communicate with development tools
over a protocol that enables inter-
process communication.

Page 46

Tab vs Space

EditorConfig

https://editorconfig.org/

Indent and Newline code can be
set for each file name and
extension.

Page 47

エディタ横断

EditorConfig

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true

# Set default charset
[*.{js,py}]
charset = utf-8

# 4 space indentation
[*.py]
indent_style = space
indent_size = 4

# Tab indentation (no size specified)
[Makefile]
indent_style = tab

Page 48

Page 49

vim

On Vim

Page 50

編集中にわかる

ALE

Asynchronous Lint Engine

https://github.com/w0rp/ale

ALE supports PHP syntax checker,
PHPStan, Phan, Psalm, PHP CS,

PHP-CS-Fixer and LSP

Page 51

ミスがわかる

Coding on Vim+ALE

Page 52

型付けされてる

Coding on Vim+ALE

https://camo.qiitausercontent.com/
63f80f6472f7de44d28a25cf275c2f80d782d94e/
68747470733a2f2f71696974612d696d6167652d73746f7265 2e73332e616d617a6f6e6177732e636f6d2f302f343132312f3 8373535663234332d353532662d663939302d373266332d
3561303835643563643334392e706e67

Typed

Page 53

リファクタ

Phpactor

Phpactor Vim Plugin Provides

Context menu

Code Navigation

Completion (It supports Vim's Omni-completion, Deoplete, NeoVim's NCM and NCM 2)

Page 54

なにそれ

Veonim

Page 55

やばい

Veonim

veonim is a simple modal IDE built on
neovim.

https://github.com/veonim/veonim

That is integrated with LSP and has a
graphical interface like IDE.

Veonim realized almost all the functions I wanted as ideal Vim.

Page 56

やばい

Veonim

I learned Veonim by @ShougoMatsu
two weeks ago.

He said that I do not use yet
because my plugins does not work.

I have not finished studying Veonim yet, but this may be a wonderful IDE