Drupal 8 - Drupal 8 - News - Help - Tutorial - And more... http://drupal8.ovh/en/rss.xml en Change a metatag dynamicly http://drupal8.ovh/en/tutoriels/336/change-a-metatag-dynamicly <span class="field field--name-title field--type-string field--label-hidden">Change a metatag dynamicly</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to change a metatag programaticly on drupal ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 07/28/2017 - 16:22</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>The metatag module provide an API (hook) to alter all meta tags : hook_metatag_metatags_view_alter</p> <p>Example:</p> <p>NOTE : This is not the drupal best practice.</p> <p><code>/**<br />  *<br />  * Implement hook_metatag_metatags_view_alter().<br />  *  - Translate 'description' metatag of the home page.<br />  * @param type $output<br />  * @param type $instance<br />  * @param type $options<br />  */<br /> function mymodule_metatag_metatags_view_alter(&amp;$output, $instance, $options) {<br />   if ($instance == 'global:frontpage') {<br />     <strong>// Use dpm or kint to get the field to change.</strong>    <br />     if (!empty($value = $output['description']['#attached']['drupal_add_html_head'][0][0]['#value'])) {<br />       $output['description']['#attached']['drupal_add_html_head'][0][0]['#value'] = <strong>"The new value";</strong><br />     }<br />   }<br /> }</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/code" hreflang="en">Code</a></li> <li><a href="/en/tags/seo" hreflang="en">SEO</a></li> <li><a href="/en/tags/hook" hreflang="en">Hook</a></li> </ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=336&amp;2=comment&amp;3=comment" token="qAynikU_i1ofS_sm6lxJcMCK-PJPsd98qlKSaoorWkQ"></drupal-render-placeholder> </section> Fri, 28 Jul 2017 14:22:29 +0000 editor 336 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/336/change-a-metatag-dynamicly#comments How to create a JSON web service on drupal 8 ? http://drupal8.ovh/en/tutoriels/335/how-to-create-a-json-web-service-on-drupal-8 <span class="field field--name-title field--type-string field--label-hidden">How to create a JSON web service on drupal 8 ?</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to create a custom JSON web service with Drupal 8 ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Tue, 07/25/2017 - 10:33</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>This is a simple example of a web service. For the example, We will make a service to multiply two numbers.</p> <h2>Create JSON WebService module</h2> <h3>Create a module.</h3> <p>Here :<strong> mywebservice</strong></p> <h3>Create route, the Web Service path.</h3> <p>Example:<br /><code>mywebservice.multiply:<br />   path: '/mywebservice/maths/multiply'<br />   defaults:<br />     _controller: '\Drupal\mywebservice\Controller\MyWebService::multiply'<br />     _title: 'MyWebService'<br />   requirements:<br />     _permission: 'access content'</code></p> <h3> Create webservice Controller</h3> <p>Example:<br /><code>&lt;?php<br /> //<br /> namespace Drupal\mywebservice\Controller;<br /> //<br /> use Drupal\Core\Controller\ControllerBase;<br /> use Symfony\Component\HttpFoundation\JsonResponse;<br /> /**<br />  * Class MyWebService.<br />  */<br /> class MyWebService extends ControllerBase {<br />   /**<br />    * Multiply.<br />    */<br />   public function multiply() {<br />     $request = \Drupal::request();<br />     $output['a'] = $request-&gt;get('a');<br />     $output['b'] = $request-&gt;get('b');<br />     $output['result'] = $output['a'] * $output['b'];<br />     return new JsonResponse($output);<br />   }<br /> }</code></p> <h2>Test the web service</h2> <p>Visit : http://yourdomain.loc/<strong>mywebservice/maths/multiply</strong><br /> Must return a JSON : <code>{"a":null,"b":null,"result":0}</code></p> <p>Visit : http://yourdomain.loc/<strong>mywebservice/maths/multiply?a=5&amp;b=2</strong><br /> Must return a JSON : <code>{"a":"5","b":"2","result":10}</code></p> <p> </p> </div> <div class="field field--name-field-file field--type-file field--label-inline"> <div class="field__label">File</div> <div class="field__item"> <span class="file file--mime-application-zip file--package-x-generic"> <a href="http://drupal8.ovh/sites/drupal/files/2017-07/mywebservice.zip" type="application/zip; length=2485">mywebservice.zip</a></span> </div> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/code" hreflang="en">Code</a></li> <li><a href="/en/tags/module" hreflang="en">Module</a></li> <li><a href="/en/tags/webservice" hreflang="en">WebService</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/251/drupal-8-restful-web-services" hreflang="en">Drupal 8 RESTful Web Services</a></div> <div class="field__item"><a href="/en/tutoriels/5/create-a-simple-module-for-drupal-8-step-2-create-simple-page" hreflang="en">Create a simple module for Drupal 8 - Step 2 - Create Simple Page</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=335&amp;2=comment&amp;3=comment" token="X6xyZNjr5Ah9SnOmJu5xg8DQwkvb08bFFHvmNdzCwLA"></drupal-render-placeholder> </section> Tue, 25 Jul 2017 08:33:14 +0000 editor 335 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/335/how-to-create-a-json-web-service-on-drupal-8#comments CSS Fluid Width Video http://drupal8.ovh/en/tutoriels/334/css-fluid-width-video <span class="field field--name-title field--type-string field--label-hidden">CSS Fluid Width Video</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to set width of a youtube video automaticly ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/nuwantha" typeof="schema:Person" property="schema:name" datatype="">nuwantha</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 07/24/2017 - 23:43</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Example :</p> <p><code>&lt;div class="video-content"&gt;<br />     &lt;!-- YouTube video code--&gt;<br />     &lt;iframe width="560" height="349" src="http://www.youtube.com/embed/THEVIDEOID" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;<br /> &lt;/div&gt;</code></p> <p><code>.video-content {<br />   position: relative;<br />   padding-bottom: 56.25%; /* 16:9 */<br />   padding-top: 25px;<br />   height: 0;<br />   iframe {<br />     position: absolute;<br />     height: 100%;<br />     top: 0;<br />     left: 0;<br />     width: 100% !important;<br />     height: 100% !important;<br />   }<br /> }</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/css" hreflang="en">CSS</a></li> <li><a href="/en/tags/theming" hreflang="en">Theming</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/22/add-css-to-a-module" hreflang="en">Add CSS stylesheets to a module</a></div> <div class="field__item"><a href="/en/tutoriels/264/basic-css-styling-tips" hreflang="en">Basic CSS Styling tips</a></div> <div class="field__item"><a href="/en/tutoriels/172/sass-scss-compile" hreflang="en">SASS SCSS LESS compile</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <a id="comment-347"></a> <article role="article" data-comment-user-id="0" about="/en/comment/347" typeof="schema:Comment" class="comment js-comment by-anonymous clearfix"> <span class="hidden" data-comment-timestamp="1500967491"></span> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__author"><span rel="schema:author"><span lang="" typeof="schema:Person" property="schema:name" datatype="">good (not verified)</span></span> </p> <p class="comment__time">Tue, 07/25/2017 - 09:24 <span property="schema:dateCreated" content="2017-07-25T07:24:51+00:00" class="rdf-meta hidden"></span> </p> <p class="comment__permalink"><a href="/en/comment/347#comment-347" hreflang="en">Permalink</a></p> </footer> <div class="comment__content"> <h3 property="schema:name" datatype=""><a href="/en/comment/347#comment-347" class="permalink" rel="bookmark" hreflang="en">good</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>hello</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=347&amp;1=default&amp;2=en&amp;3=" token="7OFUFKOcH1ula_DefNNwcVgmUuDhk0qKRNlDotVl1HI"></drupal-render-placeholder> </div> </article> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=334&amp;2=comment&amp;3=comment" token="NrqO2J5ulHhbN2O91WBkUxRZkwqHr9s5xplN8jiKN_w"></drupal-render-placeholder> </section> Mon, 24 Jul 2017 21:43:02 +0000 nuwantha 334 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/334/css-fluid-width-video#comments Install Xdebug with NginX Server http://drupal8.ovh/en/tutoriels/333/install-xdebug-nginx-server <span class="field field--name-title field--type-string field--label-hidden">Install Xdebug with NginX Server</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to install and configure Xdebug On NginX with an IDE like Netbeans, Phpstorm ... ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 07/24/2017 - 11:26</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Install Xdebug php</h2> <p><code>sudo apt install php-xdebug</code></p> <h2>Configure Xdebug</h2> <p>Example:<br /><strong>sudo gedit /etc/php/5.6/mods-available/xdebug.ini</strong></p> <p>Add (Example)<br /><code>zend_extension=xdebug.so<br /> xdebug.remote_enable=1<br /> xdebug.remote_handler=dbgp<br /> xdebug.remote_mode=req<br /> xdebug.remote_host=localhost<br /> xdebug.remote_port=9000<br /> xdebug.var_display_max_depth = -1<br /> xdebug.var_display_max_children = -1<br /> xdebug.var_display_max_data = -1<br /> xdebug.idekey = "netbeans-xdebug"</code></p> <h3>Restart nginx and php-fem (here php5.6-fpm)</h3> <p><code>sudo /etc/init.d/nginx restart<br /> sudo /etc/init.d/php5.6-fpm restart<br /> # OR<br /> sudo service nginx restart<br /> sudo service php5.6-fpm restart</code></p> <h3>Configre IDE (Here Netbeans)</h3> <p>Goto Tools-&gt;Options-&gt;PHP-&gt;Debuging<br /> Set session ID and Debugger Port if different.</p> <p>Note : Check 'Stop at first line' to test, then uncheck if you do not need.</p> <h2>Tips</h2> <p>On netBeans:<br /> Run your project in debug mode (Ctrl + F5)<br /> View Variables<br /> Step over ( F8 )<br /> Step Into ( F7 )<br /> Step Out ( Ctrl + F7 )<br /> Run to cursor ( F4 )<br /> Continue ( F5 )</p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/debug" hreflang="en">Debug</a></li> <li><a href="/en/tags/ide" hreflang="en">IDE</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/109/xdebug-install-and-configure-netbeans" hreflang="en">XDebug - Install and configure with NetBeans</a></div> <div class="field__item"><a href="/en/tutoriels/106/debug-and-display-errors-php-apache-mysql-xdebug" hreflang="en">Debug and Display errors. PHP Apache Mysql Xdebug</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=333&amp;2=comment&amp;3=comment" token="DSxFnKL4z2y7PlL4r1E6ULhcAZDrbJ1kU8A56cWc1tg"></drupal-render-placeholder> </section> Mon, 24 Jul 2017 09:26:24 +0000 editor 333 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/333/install-xdebug-nginx-server#comments Git - Errors and problems http://drupal8.ovh/en/tutoriels/332/git-errors-and-problems <span class="field field--name-title field--type-string field--label-hidden">Git - Errors and problems</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>Some Errors and problems of git repository.</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 07/24/2017 - 09:46</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Cannot push Git to remote repository with http/https</h2> <p><strong>return code 22 fatal: git-http-push failed</strong></p> <p>Edit the file config (.git/config)<br /> Change :<br /><code>[remote "origin"]<br /> fetch = +refs/heads/*:refs/remotes/origin/*<br /><strong>url = http://git.repository.url/myrepository.git</strong><br /> #<br /> # TO<br /> [remote "origin"]<br /> fetch = +refs/heads/*:refs/remotes/origin/*<br /><strong>url = http://username@git.repository.url/myrepository.git</strong><br /> #OR (Not recomended)<br /> [remote "origin"]<br /> fetch = +refs/heads/*:refs/remotes/origin/*<br /><strong>url = http://username:password@git.repository.url/myrepository.git</strong></code></p> <p>Then try again # git push origin  master</p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/git" hreflang="en">Git</a></li> <li><a href="/en/tags/error" hreflang="en">Error</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/11/helpful-git-commands" hreflang="en">Helpful git commands</a></div> <div class="field__item"><a href="/en/tutoriels/114/make-correction-on-a-git" hreflang="en">Make Correction on a git</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=332&amp;2=comment&amp;3=comment" token="e11v9JoHiQ8DQrkXhNjkgxeLTX-oM6FGxhL8VzfCacI"></drupal-render-placeholder> </section> Mon, 24 Jul 2017 07:46:37 +0000 editor 332 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/332/git-errors-and-problems#comments Install Drupal console (basic usage) http://drupal8.ovh/en/tutoriels/331/install-drupal-console-basic-usage <span class="field field--name-title field--type-string field--label-hidden">Install Drupal console (basic usage)</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to install and use drupal console with drupal 8 ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 07/21/2017 - 09:08</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Download and Install</h2> <p> </p> <h3>Download drupal console</h3> <p><code>curl https://drupalconsole.com/installer -L -o drupal.phar<br /> # OR<br /> php -r "readfile('https://drupalconsole.com/installer');" &gt; drupal.phar<br /> sudo mv drupal.phar /usr/local/bin/drupal<br /> chmod +x /usr/local/bin/drupal</code></p> <h3>Include drupal console to your project.</h3> <p><code>composer require drupal/console:~1.0</code></p> <h3>Initialize drupal console.</h3> <p><code>drupal init</code></p> <p> </p> <h3>Documentations</h3> <ul><li>https://drupalconsole.com/articles/how-to-install-drupal-console</li> <li>https://docs.drupalconsole.com/en/getting/composer.html</li> </ul><p> </p> <h3>Update drupal console</h3> <p><code>drupal self-update</code></p> <h3> The autocomplete feature.</h3> <p><code>#Bash or Zsh: Add this line to your shell configuration file:<br /> source "$HOME/.console/console.rc" 2&gt;/dev/null<br /> #Fish: Create a symbolic link<br /> ln -s ~/.console/drupal.fish ~/.config/fish/completions/drupal.fish</code></p> <p> </p> <h2>Basic Usage</h2> <p><strong>The full documentation is available from : https://docs.drupalconsole.com/en/commands/available-commands.html</strong></p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/console" hreflang="en">Console</a></li> </ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=331&amp;2=comment&amp;3=comment" token="iH7HYD98nIHBesTlCNSjJwGWoafTJ8X_e9qf2Y7K5gg"></drupal-render-placeholder> </section> Fri, 21 Jul 2017 07:08:17 +0000 editor 331 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/331/install-drupal-console-basic-usage#comments Download and Install Composer on Linux http://drupal8.ovh/en/tutoriels/330/download-and-install-composer-on-linux <span class="field field--name-title field--type-string field--label-hidden">Download and Install Composer on Linux</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to install Composer on Linux (Debian, Ubunto, Mini ...)</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 07/20/2017 - 11:29</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.</p> <h2>Download Composer</h2> <p>Link : https://getcomposer.org/download/</p> <p><code>php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"<br /> php composer-setup.php<br /> php -r "unlink('composer-setup.php');"</code></p> <p><strong>Note : For the security, you can check the setup file using SHA hash.</strong><br /> Fot that, get the latest version from https://getcomposer.org/download<br /> Example :<br /><code>#php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"</code></p> <h3> Move composer to bin</h3> <p>Make `composer` executable as a command from anywhere. Destination can be anywhere on $PATH.</p> <p><code>mv composer.phar composer<br /> chmod +x composer<br /> sudo mv composer /usr/local/bin</code></p> <h2> Check composer version</h2> <p><code>composer --version</code></p> <p>Now you can use composer form anywhare</p> <p><a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="1f06b0a3-f700-490f-8957-08711034fc8b" href="/en/tutoriels/277/create-a-drupal-8-project-using-composer" rel="nofollow">Follow this tutorial to install drupal via composer</a></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/code" hreflang="en">Code</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/202/install-and-update-composer" hreflang="en">Install and Update Composer</a></div> <div class="field__item"><a href="/en/tutoriels/42/get-composer-instalation-path" hreflang="en">Get composer instalation path</a></div> <div class="field__item"><a href="/en/tutoriels/277/create-a-drupal-8-project-using-composer" hreflang="en">Create a Drupal 8 Project using composer.</a></div> <div class="field__item"><a href="/en/tutoriels/278/manage-custom-package-using-composer" hreflang="en">Manage custom package using composer.</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=330&amp;2=comment&amp;3=comment" token="KVZEFEFRXvMYI9dTXYLdxUIlnZkkyPfUJJpT9Ni-1DM"></drupal-render-placeholder> </section> Thu, 20 Jul 2017 09:29:14 +0000 editor 330 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/330/download-and-install-composer-on-linux#comments Git Tags - Git tag usage http://drupal8.ovh/en/tutoriels/328/git-tags-git-tag-usage <span class="field field--name-title field--type-string field--label-hidden">Git Tags - Git tag usage</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to use tags (the git tag command) of git repository ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 07/07/2017 - 10:02</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h3>Tag a branche / Version on git</h3> <p><code>git tag THE_TAG_NAME</code></p> <p> </p> <h3>Push tags or a tag to origin ripository</h3> <p><code>git push --tags</code></p> <p> </p> <h3>Show tags list</h3> <p><code>git tag</code></p> <h3> Get all tags list from origin</h3> <p><code>git fetch --all --tags --prune</code></p> <p> </p> <h3>Checkout a tag (Checkout a tagged version)</h3> <p><code>git checkout tags/&lt;tag_name&gt; -b &lt;branch_name&gt;</code></p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/code" hreflang="en">Code</a></li> <li><a href="/en/tags/git" hreflang="en">Git</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/11/helpful-git-commands" hreflang="en">Helpful git commands</a></div> <div class="field__item"><a href="/en/tutoriels/308/git-tags" hreflang="en">Git Tags</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=328&amp;2=comment&amp;3=comment" token="n5k-zVEoKMrxOgHF4Mycqie34GB6fmhx0TZzFwVDkhw"></drupal-render-placeholder> </section> Fri, 07 Jul 2017 08:02:43 +0000 editor 328 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/328/git-tags-git-tag-usage#comments Drupal coding Standard and Best Practice http://drupal8.ovh/en/tutoriels/327/drupal-coding-standard-and-best-practice <span class="field field--name-title field--type-string field--label-hidden">Drupal coding Standard and Best Practice</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to use <strong>phpcs </strong>and <strong>phpcbf </strong>to check and correct<strong> drupal 8</strong> coding Standard ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 06/29/2017 - 13:05</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><blockquote><p> Create a Drupal 8 module is a good idea, but develop as Drupal is BEST.</p> </blockquote> <p>The famous tools <strong>PhpCS </strong>and <strong>PhpCBF </strong>allow you to check and correct (some) drupal coding standards and best practice errors.</p> <h2>Install Drupal coder.</h2> <p>Step 1. Download drupal coder via drush (<strong>drush dl coder</strong>) or from <strong>https://www.drupal.org/project/coder</strong> and extract into a folder <strong>out side</strong> of the drupal project.<br /> Here, for the example : <strong>/home/myhome/coder</strong></p> <p>Step 2. Download / Install additional packages using composer. (<a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="2dac87a1-d882-41c7-815e-a12dce5c74eb" href="/en/tutoriels/202/install-and-update-composer" rel="nofollow">How to install composer</a>)<br /> Example:<br /><code>cd /home/myhome/coder<br /> composer update</code></p> <p>Step 3. Configure envirenement.<br /> Example:<br /><code>export PATH="$PATH:/home/myhome/coder/vendor/bin"<br /> set PATH $PATH /home/myhome/coder/vendor/bin<br /> phpcs --config-set installed_paths /home/myhome/coder/coder_sniffer<br /> phpcbf --config-set installed_paths /home/myhome/coder/coder_sniffer</code></p> <h2> Use PhpCS anf PhpCBF</h2> <p>-&gt; Go to your custom module directory. Example : /var/www/drupal8/modules/custom/mymodule<br /> You can use phpcs using absolute path of the module. But I got <strong><em>some errors when using phpcbf</em></strong>.<br /><strong>phpcs --standard=Drupal /var/www/drupal8/modules/custom/mymodule</strong></p> <p>Example of the Errors :<br /><code>Array<br /> (<br /> [0] =&gt; Ignoring potentially dangerous file name /var/www/drupal8/modules/custom/mymodule.....<br /> [1] =&gt; can't find file to patch at input line 3</code></p> <h3>Check drupal coding Standard errors</h3> <p><code>phpcs --standard=Drupal .<br /> OR<br /> phpcs --standard=Drupal /var/www/drupal8/modules/custom/mymodule</code></p> <h3>Correst some drupal coding Standard errors (Merked as [X])</h3> <p><code>phpcbf --standard=Drupal .<br /> OR<br /> # This may not work : To test<br /> phpcbf --standard=Drupal /var/www/drupal8/modules/custom/mymodule</code></p> <h3>Check drupal Best Practice errors</h3> <p><code>phpcs --standard=DrupalPractice .<br /> OR<br /> phpcs --standard=DrupalPractice /var/www/drupal8/modules/custom/mymodule</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/en/tags/code" hreflang="en">Code</a></li> <li><a href="/en/tags/debug" hreflang="en">Debug</a></li> <li><a href="/en/tags/module" hreflang="en">Module</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/202/install-and-update-composer" hreflang="en">Install and Update Composer</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=327&amp;2=comment&amp;3=comment" token="PG_cMf-0dyBQ02oeI_IMcBhl6bm5fjx-Op9bqcyn62g"></drupal-render-placeholder> </section> Thu, 29 Jun 2017 11:05:53 +0000 editor 327 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/327/drupal-coding-standard-and-best-practice#comments Date on Linux Shell / Bash command line http://drupal8.ovh/en/tutoriels/326/date-on-linux-shell-bash-command-line <span class="field field--name-title field--type-string field--label-hidden">Date on Linux Shell / Bash command line</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>Few tips for linux terminal date. manipulate date on linux CLI.</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 06/26/2017 - 15:53</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Print / Check Date from command line</h2> <p><code>date</code></p> <h2>Set date from the command line</h2> <p><code>date +%Y%m%d -s "20170430"</code></p> <h2>Set time from the command line</h2> <p><code>date +%T -s "12:00:00"</code></p> <h2>Set time and date from the command line</h2> <p><code>date -s "30 APR 2017 12:00:00"</code></p> <p> </p> <h2>Print / Get a formatted dater</h2> <p><code>DATE=$(date +%d-%m-%Y" "%H:%M:%S);<br /> echo  $(date +%d-%m-%Y" "%H:%M:%S);</code></p> <h2>Write a file using current timestamp as file name.</h2> <p><code>echo "test"&gt; "File-$(date +%Y%m%d%H%M%S).txt";</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/en/tags/linux" hreflang="en">Linux</a></li> <li><a href="/en/tags/shell" hreflang="en">Shell</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/en/tutoriels/324/linux-shell-output-handle-stdout" hreflang="en">Linux shell output - Handle StdOut</a></div> <div class="field__item"><a href="/en/tutoriels/287/create-interactive-shell-script-prompt-for-yes-no-input" hreflang="en">Create interactive shell script. Prompt for Yes / No input</a></div> <div class="field__item"><a href="/en/tutoriels/8/linux-shell-process-bulk-images" hreflang="en">Linux Shell - Process bulk Images</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=326&amp;2=comment&amp;3=comment" token="SPDUI2ONONGMQ5McmpLPyeLathvbUwFnZs89oqj8u4E"></drupal-render-placeholder> </section> Mon, 26 Jun 2017 13:53:21 +0000 editor 326 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/326/date-on-linux-shell-bash-command-line#comments