Drush http://drupal8.ovh/en/tags/drush en Create a custom DRUSH command on drupal 8 http://drupal8.ovh/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8 <span class="field field--name-title field--type-string field--label-hidden">Create a custom DRUSH command 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 drush command for 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, 06/13/2017 - 12:28</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>To create a custom drush command, you must create a custom module <a data-entity-substitution="canonical" data-entity-type="node" data-entity-uuid="b1e18681-bcf2-4efc-bf00-d4f5d9946bbe" href="/en/tutoriels/3/create-a-simple-module-for-drupal-8" rel="nofollow">like this</a> (Here, mymodule).</p> <p>Then add a file : YOUR_MODULE.drush.inc (Here <strong>mymodule.drush.inc</strong>)</p> <p>Example :</p> <p><code>&lt;?php<br /> /**<br />  * Mymodule is a Test module, This is drush command example<br />  * mymodule<br />  */<br /> /**<br />  * Implements hook_drush_command().<br />  */<br /> function mymodule_drush_command() {<br />   $commands = [];<br />   $commands['my-cmd'] = [<br />     'description' =&gt; 'A test command my-cmd.',<br />   ];<br />   $commands['mycommand'] = [<br />     'description' =&gt; 'This is my example command.',<br />     'aliases' =&gt; ['mec'],<br />     'arguments' =&gt; [<br />       'arg1' =&gt; 'My custom argument 1.',<br />       'arg2' =&gt; 'My custom argument 2.',<br />     ],<br />     'options' =&gt; [<br />       'opt1' =&gt; 'My custom option.',<br />     ],<br />     'examples' =&gt; [<br />       'drush mec' =&gt; 'Print my example command.',<br />       'drush mec myargument' =&gt; 'Print my example command with an argument "myargument".',<br />       'drush mec myargument --opt1=myoption' =&gt; 'Print my example command with an argument "myargument" and an option "myoption".',<br />     ],<br />   ];<br />   return $commands;<br /> }<br /> /**<br />  * Call back function drush_custom_drush_command_say_hello()<br />  * The call back function name in the  following format<br />  *   drush_{module_name}_{item_id_for_command}()<br />  */<br /> function drush_mymodule_my_cmd() {<br />   // Your codes<br />   return "My Drush command 'my-cmd' is OK";<br /> }<br /> /**<br />  * Test command 2 : mycommand or mec<br />  */<br /> function drush_mymodule_mycommand($arg = '?') {<br />   // Your codes<br />   $opt1 = drush_get_option('opt1', 'N/A');<br />   drush_print("Argument : $arg, Option : $opt1");<br />   return "My Drush command 'mycommand' is OK";<br /> }</code></p> <p> </p> <h2>Print Error, Warning, Success or OK message</h2> <p><code>drush_log('Test Success message','success');<br /> drush_log('Test Warning message','warning');<br /> drush_log('Test Error message','error');</code><br /><code>drush_log('Test OK message','ok');</code><br /><code>drush_log('Test Cancel message','cancel');</code><br />  <br />  <br /> Run a drush command (Print help command).</p> <p><code>drush_invoke('help', ['cex']);</code></p> <h2> User input - Prompt for user input in Drush</h2> <h3>Ask for options</h3> <p><code>$options = [<br /> 'Test' =&gt; t('Test'),<br /> '0' =&gt; t('Error'),<br /> ];<br /> $option = drush_choice($options, t('Please choose a option.'));</code></p> <h3> Ask Yes/No Confirmation</h3> <p>NOTE : If you set the option<code><strong> -y</strong></code>, this will return <strong><code>TRUE </code></strong>without prompting.</p> <p><code>if (drush_confirm('Are you sure you want printed \'Hello world\' to the screen ?')) {<br />   drush_print('Hello world !!!');<br /> }<br /> else {<br />   drush_user_abort();<br /> }</code></p> <h3> Ask for input value</h3> <p><code>$value = drush_prompt(dt('Please enter your name'));<br /> drush_print(dt('Hello @value!', ['@value' =&gt; $value]));</code></p> <p><strong>Note : The procedure is same as on Drupal 7</strong></p> <h2>Tips</h2> <p>To get arguments, you can also use:<br /><code><strong><span>$args </span><span>= </span><em>func_get_args</em><span>();</span></strong></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-06/mymodule.zip" type="application/zip; length=2741">mymodule.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/drush" hreflang="en">Drush</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/235/execute-a-drush-command-programmatically" hreflang="en">Execute a drush command programmatically</a></div> <div class="field__item"><a href="/en/tutoriels/98/useful-drush-commands" hreflang="en">Useful Drush commands</a></div> <div class="field__item"><a href="/en/tutoriels/138/install-and-update-drush-on-linux" hreflang="en">Install and Update Drush on Linux</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=323&amp;2=comment&amp;3=comment" token="3gs1bfrFfs-DBDKxYwHn4fTDSiaaAQA3szo7OM5Ywg0"></drupal-render-placeholder> </section> Tue, 13 Jun 2017 10:28:24 +0000 editor 323 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8#comments Execute a drush command programmatically http://drupal8.ovh/en/tutoriels/235/execute-a-drush-command-programmatically <span class="field field--name-title field--type-string field--label-hidden">Execute a drush command programmatically</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 execute a drush command programmatically ?</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, 09/29/2016 - 15:49</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h3>Methodes:</h3> <p>drush_invoke (For the current site)<br /><code>drush_invoke($command, $arguments = array());</code></p> <p>drush_invoke_process<br /> This creates a new process in a new Drupal instance. There for you must specify the site alias.<br /><code>drush_invoke_process($site_alias_record, $command_name, $commandline_args = array(), $commandline_options = array(), $backend_options = TRUE);</code></p> <h3>Example 1. Enable a Module/Feature and Revert all features.</h3> <p><code>$site = drush_sitealias_get_record('@mysite');<br /> drush_invoke_process($site, 'pm-enable', array("features_dependencies","-y"));<br /> drush_invoke_process($site, 'features-revert-all', array("-y","--force"));</code></p> <p>//OR for the current site:<br /> drush_invoke_process('@self', 'features-revert-all', array("-y","--force"));<br />  </p> <p> </p> <p>Example 2. Run a drush command at  <span lang="en" xml:lang="en" xml:lang="en"><span>the installation of</span> <span>a module. </span></span></p> <p><code>function mymodule_install() {<br />     // clears the 'all' cache for current web site<br />     //Methode 1.<br />     drush_invoke('cache-clear', 'all');<br />     <br />     Or</code></p> <p><code>    //Methode2.<br />     $site = drush_sitealias_get_record('@mysite');<br />     drush_invoke_process($site, 'cache-clear', array('all'));<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/drush" hreflang="en">Drush</a></li> <li><a href="/en/tags/drupal-7" hreflang="en">Drupal 7</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/98/useful-drush-commands" hreflang="en">Useful Drush commands</a></div> <div class="field__item"><a href="/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8" hreflang="en">Create a custom DRUSH command on drupal 8</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=235&amp;2=comment&amp;3=comment" token="hW2IOZmCmwFRCThT3QIYuPVZe3WfYbKntb8NOSMWcoA"></drupal-render-placeholder> </section> Thu, 29 Sep 2016 13:49:30 +0000 editor 235 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/235/execute-a-drush-command-programmatically#comments Drupal MySQL Database Import and Export via Drush http://drupal8.ovh/en/tutoriels/206/drupal-mysql-database-import-and-export-via-drush <span class="field field--name-title field--type-string field--label-hidden">Drupal MySQL Database Import and Export via Drush</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 Import and Export Drupal MySQL Database via Drush ?</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/25/2016 - 14:50</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Export Drupal 8 MySQL Database via Drush</h2> <p><code>drush cr<br /> drush sql-dump &gt; /pathto/mysql-dump-drupal8.sql</code></p> <h2>Import Drupal 8 and MySQL Database via Drush</h2> <p><code>drush sql-drop<br /> drush sql-cli<br /> mysql&gt; source /pathto/mysql-dump-drupal8.sql</code></p> <h2>Export Drupal 7 MySQL Database via Drush</h2> <p><code>drush cc all<br /> drush sql-dump &gt; /pathto/mysql-dump-drupal7.sql</code></p> <h2>Import Drupal 7 MySQL Database via Drush (Same as Drupal 8)</h2> <p><code>//Method 1</code><br /><code>drush sql-drop</code><br /><code>drush sql-cli &lt; /pathto/mysql-dump-drupal.sql<br /> //OR : </code><code>drush sqlc &lt; /pathto/mysql-dump-drupal.sql</code><br /> If you have a error message like: "<strong>Access denied; you need the SUPER privilege for this operation</strong>" Try the Method 2</p> <p><code>//Method 2<br /> drush sql-drop<br /> drush sql-cli<br /> mysql&gt; source /pathto/mysql-dump-drupal8.sql</code></p> <p> </p> <h2>Export to a gz compressed file</h2> <p><code>drush sql-dump <strong>| gzip</strong> &gt; mysql-dump-drupal.sql.gz<br /> drush sql-dump --gzip &gt; mysql-dump-drupal.sql.gz</code></p> <h2>Import a GZ compressed file</h2> <p><code>gunzip &lt; mysql-dump-drupal.sql.gz | drush sqlc</code></p> <p> </p> <p>Options (Example)</p> <p><em>drush sql-dump --data-only --gzip --tables-list="node,users"</em></p> <p><em>More : </em>https://drushcommands.com/drush-8x/sql/sql-dump/</p> <p> </p> <h2>Drush shortcuts</h2> <p>drush sql-cli = drush sqlc<br /> drush sql-query = drush sqlq</p> <h2>Drush sql commandes</h2> <p>drush sql-cli        //Open a SQL command-line interface using Drupal's User and Password<br /> drush sql-connect<br /> drush sql-create    //Create a database<br /> drush sql-drop         // Delete All tables of the current database<br /> drush sql-dump         // Export current drupal Database to a file (like mysqldump)<br /> drush sql-query     //Execute a query<br /> drush sql-sanitize    //Run sanitization operations on the current database<br /> drush sql-sync        //Copies the database contents from a source site to a target site. Transfers the database dump via rsync</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/drupal-7" hreflang="en">Drupal 7</a></li> <li><a href="/en/tags/drush" hreflang="en">Drush</a></li> <li><a href="/en/tags/database" hreflang="en">Database</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/113/mysql-backup-restore-syntax" hreflang="en">Mysql Database Backup / Restore Syntax</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=206&amp;2=comment&amp;3=comment" token="gj_MJlDiaHUOAqN-wlgZj2IAR6pu9Ra3aZO9nUKszuE"></drupal-render-placeholder> </section> Mon, 25 Jul 2016 12:50:43 +0000 editor 206 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/206/drupal-mysql-database-import-and-export-via-drush#comments Cache Clearing and rebuilding methods for Drupal 8 http://drupal8.ovh/en/tutoriels/147/cache-clearing-and-rebuilding-methods-for-drupal-8 <span class="field field--name-title field--type-string field--label-hidden">Cache Clearing and rebuilding methods for 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>What are the methods for clearing or rebuilding Drupal 8 cache, using site url, drush SQL ... ?</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">Wed, 05/25/2016 - 09:55</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Site URL</h2> <p>1. Go to <strong>Administration &gt; Configuration &gt; Development &gt; Performance</strong><br />  (/admin/config/development/performance)<br /> 2. Click on "<strong>Clear all caches</strong>"</p> <h2>Drush</h2> <p><code>drush cache-rebuild<br /> OR<br /> drush cr</code></p> <h2>Programmatically using PHP (From a drupal module)<code> </code></h2> <p><code>db_query("DELETE FROM {cache};");</code><br />  </p> <h2>By SQL / phpMyAdmin interface</h2> <p>Clear all tables that start with cache_ (CAUTION : Do not DELETE tables)<br /> Ex:<br /><code>TRUNCATE cache_config;<br /> TRUNCATE cache_container;<br /> TRUNCATE cache_data;<br /> TRUNCATE cache_default;<br /> TRUNCATE cache_discovery;<br /> TRUNCATE cache_dynamic_page_cache;<br /> TRUNCATE cache_entity;<br /> TRUNCATE cache_menu;<br /> TRUNCATE cache_render;<br /> TRUNCATE cache_toolbar;</code></p> <h2>Run update.php</h2> <p>Running update.php (<code>/update.php</code>) is another way of clearing the cache.<br /> If you cannot login or have no user 1 rights you will need to set in :<br /><code>/sites/default/settings.php<br /> $update_free_access = TRUE;  </code><br /><strong>Do not forget to set this back to FALSE afterwards.</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/code" hreflang="en">Code</a></li> <li><a href="/en/tags/server" hreflang="en">Server</a></li> <li><a href="/en/tags/drush" hreflang="en">Drush</a></li> <li><a href="/en/tags/cache" hreflang="en">Cache</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/155/drupal-8-tags-based-cache-system" hreflang="en">Drupal 8 Tags based cache system</a></div> <div class="field__item"><a href="/en/tutoriels/256/drupal-8-cache-api" hreflang="en">Drupal 8 Cache API</a></div> <div class="field__item"><a href="/en/tutoriels/158/cache-drupal-8-render-arrays" hreflang="en">Cache Drupal 8 Render Arrays</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=147&amp;2=comment&amp;3=comment" token="75VKBOO5PPHDKxuDwIu1DqdnoPwlTe88CQUDvGbe9P0"></drupal-render-placeholder> </section> Wed, 25 May 2016 07:55:33 +0000 editor 147 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/147/cache-clearing-and-rebuilding-methods-for-drupal-8#comments Migrate from Drupal7 to Drupal8 http://drupal8.ovh/en/tutoriels/143/migrate-from-drupal7-to-drupal8 <span class="field field--name-title field--type-string field--label-hidden">Migrate from Drupal7 to Drupal8</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 Migrate from Drupal7 to Drupal8 using drupal migration tool ?</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, 05/17/2016 - 21:09</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Example (basic)</p> <p><code>drush migrate<span>-</span>upgrade <span>--</span>legacy<span>-</span>db<span>-</span>url<span>=</span>mysql<span>:</span><span>//user:password@server/db --legacy-root=http://mydrupal6or7site.com</span></code></p> <p><span>Migrate UI (Website)</span><br /><code>/upgrade</code></p> <p>Link : https://www.drupal.org/node/2350603</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/drush" hreflang="en">Drush</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=143&amp;2=comment&amp;3=comment" token="m0JQ3LDfTlA3MlVfLcy-adhQ5KemJwh80UWRrp54hhE"></drupal-render-placeholder> </section> Tue, 17 May 2016 19:09:57 +0000 editor 143 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/143/migrate-from-drupal7-to-drupal8#comments Install and Update Drush on Linux http://drupal8.ovh/en/tutoriels/138/install-and-update-drush-on-linux <span class="field field--name-title field--type-string field--label-hidden">Install and Update Drush 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>Install and Update Drush on Linux</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">Sun, 05/08/2016 - 13:53</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><pre> <code class="sh hljs bash"><span class="hljs-comment"># Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.</span> php -r <span class="hljs-string">"readfile('http://files.drush.org/drush.phar');"</span> &gt; drush <span class="hljs-comment"># Or use our upcoming release: php -r "readfile('http://files.drush.org/drush-unstable.phar');" &gt; drush</span> <span class="hljs-comment"># Test your install.</span> php drush core-status <span class="hljs-comment"># Make `drush` executable as a command from anywhere. Destination can be anywhere on $PATH.</span> chmod +x drush sudo mv drush /usr/<span class="hljs-built_in">local</span>/bin <span class="hljs-comment"># Optional. Enrich the bash startup file with completion and aliases.</span> drush init</code></pre> <p> </p> <p>Aa a script: (Run sudo a command first, like sudo ls)</p> <pre> <code class="sh hljs bash">php -r <span class="hljs-string">"readfile('http://files.drush.org/drush.phar');"</span> &gt; drush chmod +x drush sudo mv drush /usr/<span class="hljs-built_in">local</span>/bin drush init </code> </pre> <p> </p> <h2>Update drush (or also install)</h2> <p><code class="sh hljs bash">sudo php -r <span class="hljs-string">"readfile('http://files.drush.org/drush.phar');"</span> &gt; /usr/<span class="hljs-built_in">local</span>/bin/drush<br /> chmod +x /usr/<span class="hljs-built_in">local</span>/bin/drush<br /> drush init</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/drush" hreflang="en">Drush</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/98/useful-drush-commands" hreflang="en">Useful Drush commands</a></div> <div class="field__item"><a href="/en/tutoriels/320/download-and-install-drupal-8" hreflang="en">Download and Install drupal 8.</a></div> <div class="field__item"><a href="/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8" hreflang="en">Create a custom DRUSH command on drupal 8</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=138&amp;2=comment&amp;3=comment" token="nIaFLnLhuMdzGXHOU9dWh9I_4L0DR0Bwu6FnuvMl_-U"></drupal-render-placeholder> </section> Sun, 08 May 2016 11:53:52 +0000 editor 138 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/138/install-and-update-drush-on-linux#comments Useful Drush commands http://drupal8.ovh/en/tutoriels/98/useful-drush-commands <span class="field field--name-title field--type-string field--label-hidden">Useful Drush commands</span> <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, 01/11/2016 - 16:28</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>To handle drupal with drust, First of all, you must install drush, and execute drush command from your drupal instalation folder.</p> <ul><li>For default or single site instalation, just put on<strong> drupal root folder</strong> (Ex : <code>/var/www/drupal8</code>)</li> <li>For Multi sites, put in to the <strong>site folder</strong> (Ex : <code>/var/www/drupal8/sites/mysite1</code>)</li> </ul><p> </p> <p>First command : Status<br /><code>drush status</code></p> <p>Download and active a module<br /><code>drush en module_name -y</code></p> <p>Clear All Cache<br /> On D7 # <code>drush cc all</code><br /> On D8 # <code>drush cr</code></p> <p>Get a user login url ( Tempory)<br /><code>drush uli<br /> drush uli [user_id]<br /> #Set a user password (Here : USER=admin)<br /> drush upwd --password="new admin password" "admin" </code></p> <p>Set / Change User password<br /> drush upwd USERNAME --password="The_New_Password"<br /> Example : <code>drush upwd admin --password=admin</code></p> <h3>Set / Get Variable and configuration</h3> <p>Drupal 7<br /> variable-set (vset)<br /> drush vset variable_name value<br /> Example : <code>drush variable-set stage_file_proxy_origin "http://www.drupal8.ovh"</code></p> <p>Drupal 8<br /> config-set<br /> drush config-set config_name field value<br /> Example : <code>drush config-set stage_file_proxy.settings origin 'http://www.drupal8.ovh' -y</code></p> <p> </p> <h2>Install drupal from drush</h2> <p>drush dl drupal --drupal-project-rename=example<br /> cd example<br /> drush site-install standard --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]'<br /> Options<br /> --site-name=Example --account-name=admin --account-pass=adminpassword<br /> Example : <br /><code>drush site-install standard --db-url='mysql://drupal:drupal@database/drupal' --site-name=D8 --account-name=admin --account-pass=admin --notify=0</code></p> <p>Example 2 : Install drupal 8 using sqlite database<br /><code>drush site-install standard --db-url='sqlite://sites/default/files/.ht.db.sqlite' --site-name=D8 --account-name=admin --account-pass=admin --notify=0 --account-mail=name@mail.com</code></p> <h3>Enable few usefull contrib modules.</h3> <p><code>drush en workbench workbench_moderation youtube imce linkit captcha honeypot securelogin pathauto -y<br /> drush en admin_toolbar admin_toolbar_tools -y<br /> drush en coffee features features_ui -y</code></p> <p>Enable drupal development modules.</p> <p><code>drush en devel kint coffee -y</code></p> <p> </p> <h3>Update disabled modules using Drush</h3> <p>The option --check-disabled Check for updates of disabled modules and themes. This allow you to update modules and themes codes even disabled.<br /> The option --lock allow to exclude a module<br /> Example :<br /><code><span>drush up; # Update codes and database<br /> drush upc; # Update codes only<br /> drush updb; # Update database only</span><br /><span>drush pm-</span><span>update </span><span>--</span><span>lock</span><span>=</span><span>MODULE_TO_EXCLUDE</span><br /> drush pm-updatecode --check-disabled<br /> #OR, shortcut :<br /> drush upc --check-disabled</code><br /> NOTE :  To avoid accidentally update and show the list before update, Do not use the option <strong>-y</strong>.</p> <p> </p> <h3>Get Set Variables / State (set-state / get-state)</h3> <p><strong>Put the site in maintenance mode : Put Site Online / Offline</strong><br /><code><span>drush sset system</span><span>.</span><span>maintenance_mode </span><span>1 // To set</span></code><br /><code><span>drush sget system</span><span>.</span><span>maintenance_mode // To check</span></code><br /><code><span>drush sset system</span><span>.</span><span>maintenance_mode </span><span>0 // To Exit maintenance mode</span></code><br /> Linke on drupal 7 : drush vset maintenance_mode 1</p> <h3>Get / Set Configuration</h3> <p><code>#Get site title<br /> drush cget system.site<br /> #Get front page<br /> drush cget system.site page.front<br /> #Set front page<br /> drush config-set system.site page.front my-new-front-page<br /> #Set a custom config's value. Ex:  configname=mumodule.settings, key is ['site']['section']['page']['title'] = 'My page title'<br /> drush cset mumodule.settings site.section.page.title 'My page title'</code></p> <p><code>(</code>http://drushcommands.com/drush-8x/core/site-install/ for More info<code>)</code></p> <p>Update Database (/update.php)<br /><code>drush updatedb</code></p> <p>http://drushcommands.com/</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/drupal-7" hreflang="en">Drupal 7</a></li> <li><a href="/en/tags/drush" hreflang="en">Drush</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/138/install-and-update-drush-on-linux" hreflang="en">Install and Update Drush on Linux</a></div> <div class="field__item"><a href="/en/tutoriels/95/install-drush-on-widows" hreflang="en">Install drush on Widows</a></div> <div class="field__item"><a href="/en/tutoriels/235/execute-a-drush-command-programmatically" hreflang="en">Execute a drush command programmatically</a></div> <div class="field__item"><a href="/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8" hreflang="en">Create a custom DRUSH command on drupal 8</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-190"></a> <article role="article" data-comment-user-id="172" about="/en/comment/190" typeof="schema:Comment" class="comment js-comment clearfix"> <span class="hidden" data-comment-timestamp="1497260012"></span> <footer class="comment__meta"> <article typeof="schema:Person" about="/index.php/en/users/hasan-raza90" class="profile"> </article> <p class="comment__author"><span rel="schema:author"><span lang="" about="/en/users/hasan-raza90" typeof="schema:Person" property="schema:name" datatype="">hasan.raza90</span></span> </p> <p class="comment__time">Mon, 06/12/2017 - 11:33 <span property="schema:dateCreated" content="2017-06-12T09:33:32+00:00" class="rdf-meta hidden"></span> </p> <p class="comment__permalink"><a href="/en/comment/190#comment-190" hreflang="en">Permalink</a></p> </footer> <div class="comment__content"> <h3 property="schema:name" datatype=""><a href="/en/comment/190#comment-190" class="permalink" rel="bookmark" hreflang="en">Thanks For Sharing Drush…</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>Thanks For Sharing Drush commands, very helpful</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=190&amp;1=default&amp;2=en&amp;3=" token="8Ggz8YvZ-0TKI7ZxChb1M1mtk3j_DKNS84GBgQ7UnYs"></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=98&amp;2=comment&amp;3=comment" token="GuzD-p87H_iMGzhXSG-7GsvLKPVAbPv4TFIYyf7wmGQ"></drupal-render-placeholder> </section> Mon, 11 Jan 2016 15:28:24 +0000 editor 98 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/98/useful-drush-commands#comments Some Features commands (drush) http://drupal8.ovh/en/tutoriels/97/some-features-commands-drush <span class="field field--name-title field--type-string field--label-hidden">Some Features commands (drush)</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 enable a feature using drush command ?<br /> How to revert a feature using drush cli ?<br /> How to revert all features using drush command ?<br /> How to recreate a feature using drush cli (update a feature) ?</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, 01/11/2016 - 16:25</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Enable a Features<br /><code>drush en feature_name</code></p> <p>Revert a feature<br /><code>drush fr freture_name</code></p> <p>Revert all features<br /><code>drush fra -y</code><br /> #OR Also<br /><code>drush fr-all</code></p> <p>Recreate a Feature (Update a Feature)<br /><code>drush fu freture_name</code></p> <h3>Disable a feature</h3> <p>To disable a feature, visit the Feature administration page (/admin/structure/features), deselect the appropriate checkbox and <strong>Save </strong>settings.<br /><em><strong>CAUTION </strong>: Disabling the feature module is supposed to also disable all the functionality that was defined by it. That is, remove node types that were created by it, etc...</em></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/shell" hreflang="en">Shell</a></li> <li><a href="/en/tags/drush" hreflang="en">Drush</a></li> <li><a href="/en/tags/features" hreflang="en">Features</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=97&amp;2=comment&amp;3=comment" token="wIdXtZVON3VV7yM9XwEabzXB6PCrS4K8x_s_nzrt1ZQ"></drupal-render-placeholder> </section> Mon, 11 Jan 2016 15:25:24 +0000 editor 97 at http://drupal8.ovh http://drupal8.ovh/en/tutoriels/97/some-features-commands-drush#comments