Projekt

Obecné

Profil

Development » Historie » Revize 12

Revize 11 (Tomáš Ballák, 2020-04-06 17:58) → Revize 12/13 (Tomáš Ballák, 2020-04-06 18:02)

h1. Development 

 * pro vývoj využíváme editor Visual Studio Code 

 h2. Visual Studio Code 

 * každý projekt by měl mít svůj vlastní *workspace* 
 * pro vyznačení všech souborů/adresářů patřících do workspace je potřeba do @folders@ připsat všechny cesty 

 <pre><code class="json"> 
 "folders": [ 
	 { 
			 "path": "." 
	 } 
 ] 

 </code></pre> 

 * nastavení jednotlivých rozšíření a editoru lze zakomponovat pod klíč @settings@ 

 <pre><code class="json"> 
 "settings": { 
	 "php.suggest.basic":false, 
	 "files.autoSave": "afterDelay", 
	 "php-cs-fixer.onsave": false, 
	 "php-cs-fixer.rules": "@PSR2", 
	 "php-cs-fixer.config": ".php_cs", 
	 "php-cs-fixer.executablePath": "${workspaceRoot}/vendor/bin/php-cs-fixer", 
	 "php-cs-fixer.executablePathWindows": "${workspaceRoot}\\vendor\\bin\\php-cs-fixer" 
 } 
 </code></pre> 

 * workspace má pro sebe nastavený seznam doporučených rozšíření 

 <pre><code class="json"> 
 "extensions": { 
	 "recommendations": [ 
		 "vscode-icons-team.vscode-icons", 
		 "felixfbecker.php-intellisense", 
		 "junstyle.php-cs-fixer" 
	 ] 
 } 

 </code></pre> 

 * do workspace je přidán i linter, které lze přes @F1@ spustit pro složku @src@ 

 <pre><code class="json"> 
 "tasks": { 
	 "version": "2.0.0", 
	 "tasks": [{ 
		 "label": "PHP Linter", 
		 "command": "${workspaceRoot}/vendor/bin/php-cs-fixer", 
		 "args": ["fix", "--dry-run", "--config", ".php_cs", "--stop-on-violation", "--using-cache=no"], 
		 "windows":{ 
			 "command": "${workspaceRoot}\\vendor\\bin\\php-cs-fixer", 
			 "args": ["fix", "--dry-run", "--config", ".php_cs", "--stop-on-violation", "--using-cache=no"], 
		 } 
	 }] 
 } 
 </code></pre> 

 * 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 
 * zatím nefunkční 

 <pre><code class="json"> 
 "launch": { 
	 "configurations": [{ 
            "name": "Listen for XDebug", 
            "type": "php", 
            "request": "launch", 
		 "port": 9000, 
		 "pathMappings": {   
			 "/var/www/symfony/public": "${workspaceRoot}/public" 
		 }}] 
 } 

 </code></pre> 

 h2. PHP Linter 

 * 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* 

 <pre><code class="php"> 
 ?php 
 $finder = PhpCsFixer\Finder::create() 
     ->in(__DIR__.'/src') 
     ->notPath('Kernel.php') 

 ; 

 return PhpCsFixer\Config::create() 
     ->setRules(array( 
         '@Symfony' => true, 
         'array_indentation' => true, 
         'array_syntax' => array('syntax' => 'short'), 
         'combine_consecutive_unsets' => true, 
         'method_separation' => true, 
         'no_multiline_whitespace_before_semicolons' => true, 
         'single_quote' => true, 

         'binary_operator_spaces' => array( 
             'align_double_arrow' => false, 
             'align_equals' => false, 
         ), 
         'blank_line_before_statement' => array('statements' => array( 
             'return', 
         )), 
         'braces' => array( 
             'allow_single_line_closure' => true, 
             'position_after_functions_and_oop_constructs' => 'same' 
         ), 
         'cast_spaces' => true, 
         'class_definition' => array('singleLine' => true), 
         'concat_space' => array('spacing' => 'none'), 
         'hash_to_slash_comment' => true, 
         'no_extra_consecutive_blank_lines' => array( 
             'curly_brace_block', 
             'extra', 
             'break', 
             'continue', 
             'parenthesis_brace_block', 
             'return', 
             'square_brace_block', 
             'throw', 
             'use', 
         ), 
         'no_whitespace_before_comma_in_array' => true, 
         'ordered_imports' => array('imports_order' => array( 
             'const', 
             'class', 
             'function' 
         ), 'sort_algorithm' => 'length'), 
         'short_scalar_cast' => true, 
         'simplified_null_return' => true, 
         'single_import_per_statement' => true, 
         'single_line_after_imports' => true, 
         'single_line_comment_style' => true, 
         'standardize_increment' => true, 
         'standardize_not_equals' => true, 
         'space_after_semicolon' => array( 
             'remove_in_empty_for_expressions' => true, 
         ), 
         'switch_case_semicolon_to_colon' => true, 
         'switch_case_space' => true, 
         'ternary_operator_spaces' => true, 
         'ternary_to_null_coalescing' => true, 
         'trim_array_spaces' => true, 
         'unary_operator_spaces' => true, 
         'visibility_required' => true, 
         'whitespace_after_comma_in_array' => true, 
         'align_multiline_comment' => true, 
         'constant_case' => true, 
         'declare_equal_normalize' => true, 
         'elseif' => true, 
         'function_declaration' => true, 
         'function_typehint_space' => true, 
         'global_namespace_import' => array( 
             'import_classes' => true, 
             'import_constants' => true, 
             'import_functions' => true, 
         ), 
         'include' => true, 
         'linebreak_after_opening_tag' => true, 
         'list_syntax' => array('syntax' => 'short'), 
         'lowercase_cast' => true, 
         'lowercase_keywords' => true, 
         'lowercase_static_reference' => true, 
         'magic_constant_casing' => true, 
         'magic_method_casing' => true, 
         'method_argument_space' => array( 
             'on_multiline' => 'ensure_fully_multiline', 
             'keep_multiple_spaces_after_comma' => false, 
         ) 
     )) 
     //->setIndent("\t") 
     ->setLineEnding("\n") 
     ->setFinder($finder) 
 ; 

 </code></pre>