Development » Historie » Verze 12
Tomáš Ballák, 2020-04-06 18:02
1 | 1 | Tomáš Ballák | h1. Development |
---|---|---|---|
2 | |||
3 | * pro vývoj využíváme editor Visual Studio Code |
||
4 | |||
5 | h2. Visual Studio Code |
||
6 | |||
7 | * každý projekt by měl mít svůj vlastní *workspace* |
||
8 | 5 | Tomáš Ballák | * pro vyznačení všech souborů/adresářů patřících do workspace je potřeba do @folders@ připsat všechny cesty |
9 | 6 | Tomáš Ballák | |
10 | 3 | Tomáš Ballák | <pre><code class="json"> |
11 | "folders": [ |
||
12 | { |
||
13 | "path": "." |
||
14 | } |
||
15 | 7 | Tomáš Ballák | ] |
16 | 3 | Tomáš Ballák | |
17 | </code></pre> |
||
18 | |||
19 | 2 | Tomáš Ballák | * nastavení jednotlivých rozšíření a editoru lze zakomponovat pod klíč @settings@ |
20 | |||
21 | <pre><code class="json"> |
||
22 | "settings": { |
||
23 | "php.suggest.basic":false, |
||
24 | "files.autoSave": "afterDelay", |
||
25 | "php-cs-fixer.onsave": false, |
||
26 | "php-cs-fixer.rules": "@PSR2", |
||
27 | "php-cs-fixer.config": ".php_cs", |
||
28 | "php-cs-fixer.executablePath": "${workspaceRoot}/vendor/bin/php-cs-fixer", |
||
29 | "php-cs-fixer.executablePathWindows": "${workspaceRoot}\\vendor\\bin\\php-cs-fixer" |
||
30 | 7 | Tomáš Ballák | } |
31 | 2 | Tomáš Ballák | </code></pre> |
32 | |||
33 | 1 | Tomáš Ballák | * workspace má pro sebe nastavený seznam doporučených rozšíření |
34 | |||
35 | <pre><code class="json"> |
||
36 | "extensions": { |
||
37 | "recommendations": [ |
||
38 | "vscode-icons-team.vscode-icons", |
||
39 | "felixfbecker.php-intellisense", |
||
40 | "junstyle.php-cs-fixer" |
||
41 | ] |
||
42 | } |
||
43 | |||
44 | </code></pre> |
||
45 | 8 | Tomáš Ballák | |
46 | 9 | Tomáš Ballák | * do workspace je přidán i linter, které lze přes @F1@ spustit pro složku @src@ |
47 | 7 | Tomáš Ballák | |
48 | <pre><code class="json"> |
||
49 | "tasks": { |
||
50 | "version": "2.0.0", |
||
51 | "tasks": [{ |
||
52 | "label": "PHP Linter", |
||
53 | "command": "${workspaceRoot}/vendor/bin/php-cs-fixer", |
||
54 | "args": ["fix", "--dry-run", "--config", ".php_cs", "--stop-on-violation", "--using-cache=no"], |
||
55 | "windows":{ |
||
56 | "command": "${workspaceRoot}\\vendor\\bin\\php-cs-fixer", |
||
57 | "args": ["fix", "--dry-run", "--config", ".php_cs", "--stop-on-violation", "--using-cache=no"], |
||
58 | } |
||
59 | }] |
||
60 | } |
||
61 | 10 | Tomáš Ballák | </code></pre> |
62 | |||
63 | 11 | Tomáš Ballák | * pro debug kódu v php, je připraven příkaz v @launch@, který by měl spolu s nainstalovaný rozšířením a konfigurací *php_fpm* containeru umožnit debug našeho projektu |
64 | 10 | Tomáš Ballák | * zatím nefunkční |
65 | |||
66 | <pre><code class="json"> |
||
67 | "launch": { |
||
68 | "configurations": [{ |
||
69 | "name": "Listen for XDebug", |
||
70 | "type": "php", |
||
71 | "request": "launch", |
||
72 | "port": 9000, |
||
73 | "pathMappings": { |
||
74 | "/var/www/symfony/public": "${workspaceRoot}/public" |
||
75 | }}] |
||
76 | } |
||
77 | 7 | Tomáš Ballák | |
78 | </code></pre> |
||
79 | 12 | Tomáš Ballák | |
80 | h2. PHP Linter |
||
81 | |||
82 | * nainstalované rozšíření do vscode, umožňuje po stisknutí kombinace kláves, naformátovat soubor, podle dané metriky/formátu a konfiguračního souboru *.php_cs* |
||
83 | |||
84 | <pre><code class="php"> |
||
85 | ?php |
||
86 | $finder = PhpCsFixer\Finder::create() |
||
87 | ->in(__DIR__.'/src') |
||
88 | ->notPath('Kernel.php') |
||
89 | |||
90 | ; |
||
91 | |||
92 | return PhpCsFixer\Config::create() |
||
93 | ->setRules(array( |
||
94 | '@Symfony' => true, |
||
95 | 'array_indentation' => true, |
||
96 | 'array_syntax' => array('syntax' => 'short'), |
||
97 | 'combine_consecutive_unsets' => true, |
||
98 | 'method_separation' => true, |
||
99 | 'no_multiline_whitespace_before_semicolons' => true, |
||
100 | 'single_quote' => true, |
||
101 | |||
102 | 'binary_operator_spaces' => array( |
||
103 | 'align_double_arrow' => false, |
||
104 | 'align_equals' => false, |
||
105 | ), |
||
106 | 'blank_line_before_statement' => array('statements' => array( |
||
107 | 'return', |
||
108 | )), |
||
109 | 'braces' => array( |
||
110 | 'allow_single_line_closure' => true, |
||
111 | 'position_after_functions_and_oop_constructs' => 'same' |
||
112 | ), |
||
113 | 'cast_spaces' => true, |
||
114 | 'class_definition' => array('singleLine' => true), |
||
115 | 'concat_space' => array('spacing' => 'none'), |
||
116 | 'hash_to_slash_comment' => true, |
||
117 | 'no_extra_consecutive_blank_lines' => array( |
||
118 | 'curly_brace_block', |
||
119 | 'extra', |
||
120 | 'break', |
||
121 | 'continue', |
||
122 | 'parenthesis_brace_block', |
||
123 | 'return', |
||
124 | 'square_brace_block', |
||
125 | 'throw', |
||
126 | 'use', |
||
127 | ), |
||
128 | 'no_whitespace_before_comma_in_array' => true, |
||
129 | 'ordered_imports' => array('imports_order' => array( |
||
130 | 'const', |
||
131 | 'class', |
||
132 | 'function' |
||
133 | ), 'sort_algorithm' => 'length'), |
||
134 | 'short_scalar_cast' => true, |
||
135 | 'simplified_null_return' => true, |
||
136 | 'single_import_per_statement' => true, |
||
137 | 'single_line_after_imports' => true, |
||
138 | 'single_line_comment_style' => true, |
||
139 | 'standardize_increment' => true, |
||
140 | 'standardize_not_equals' => true, |
||
141 | 'space_after_semicolon' => array( |
||
142 | 'remove_in_empty_for_expressions' => true, |
||
143 | ), |
||
144 | 'switch_case_semicolon_to_colon' => true, |
||
145 | 'switch_case_space' => true, |
||
146 | 'ternary_operator_spaces' => true, |
||
147 | 'ternary_to_null_coalescing' => true, |
||
148 | 'trim_array_spaces' => true, |
||
149 | 'unary_operator_spaces' => true, |
||
150 | 'visibility_required' => true, |
||
151 | 'whitespace_after_comma_in_array' => true, |
||
152 | 'align_multiline_comment' => true, |
||
153 | 'constant_case' => true, |
||
154 | 'declare_equal_normalize' => true, |
||
155 | 'elseif' => true, |
||
156 | 'function_declaration' => true, |
||
157 | 'function_typehint_space' => true, |
||
158 | 'global_namespace_import' => array( |
||
159 | 'import_classes' => true, |
||
160 | 'import_constants' => true, |
||
161 | 'import_functions' => true, |
||
162 | ), |
||
163 | 'include' => true, |
||
164 | 'linebreak_after_opening_tag' => true, |
||
165 | 'list_syntax' => array('syntax' => 'short'), |
||
166 | 'lowercase_cast' => true, |
||
167 | 'lowercase_keywords' => true, |
||
168 | 'lowercase_static_reference' => true, |
||
169 | 'magic_constant_casing' => true, |
||
170 | 'magic_method_casing' => true, |
||
171 | 'method_argument_space' => array( |
||
172 | 'on_multiline' => 'ensure_fully_multiline', |
||
173 | 'keep_multiple_spaces_after_comma' => false, |
||
174 | ) |
||
175 | )) |
||
176 | //->setIndent("\t") |
||
177 | ->setLineEnding("\n") |
||
178 | ->setFinder($finder) |
||
179 | ; |
||
180 | |||
181 | </code></pre> |