Drupal console
-
Upload
martin-hason -
Category
Software
-
view
485 -
download
0
Transcript of Drupal console
DRUPAL CONSOLEWWW.DRUPALCONSOLE.COM
Martin Hasoň12. 11. 2015
8. setkání přátel Symfony a Drupal v Brně
CO JE DRUPAL CONSOLEKolekce příkazů pro generování kódu a práci s Drupal 8.Narozdíl od Drush je použita Symfony Console.Nástroj umožňující ovládat a nastavit Drupal8 bezwebového rozhraní.
Instalace$ php r "readfile('http://drupalconsole.com/installer');" | php$ mv console.phar /usr/local/bin/drupal$ drupal init
STAŽENÍ DRUPAL8$ drupal site:new demo
[+] Getting releases for DrupalPlease select your favorite release [8.0.0rc3 ] 8.0.0rc3 [8.0.0rc2 ] 8.0.0rc2 [8.0.0rc1 ] 8.0.0rc1 [8.0.0beta16 ] 8.0.0beta16 [8.0.0beta15 ] 8.0.0beta15 [8.0.0beta14 ] 8.0.0beta14 [8.0.0beta13 ] 8.0.0beta13 [8.0.0beta12 ] 8.0.0beta12 [8.0.0beta11 ] 8.0.0beta11 [8.0.0beta10 ] 8.0.0beta10 [8.0.0beta9 ] 8.0.0beta9 [8.0.0beta7 ] 8.0.0beta7 [8.0.0beta6 ] 8.0.0beta6 [8.0.0beta4 ] 8.0.0beta4 [8.0.0beta3 ] 8.0.0beta3 [8.0.0beta2 ] 8.0.0beta2 [8.0.0beta1 ] 8.0.0beta1 [8.0.0alpha15] 8.0.0alpha15 [8.0.0alpha14] 8.0.0alpha14 [8.0.xdev ] 8.0.xdev > 8.0.0rc3[+] Downloading Drupal 8.0.0rc3[+] Extracting files for Drupal 8.0.0rc3[+] Drupal 8.0.0rc3 was downloaded in directory demo
INSTALACE DRUPAL8$ cd demo$ drupal site:install
Select Drupal profile to be installed [Minimal ] Minimal [Standard] Standard > StandardSelect language for your Drupal installation [English]: Czechcommands.migrate.setup.migrations.questions.dbtype [SQLite ] SQLite [MySQL, MariaDB, Percona Server, or equivalent] MySQL, MariaDB, Percona Server, or equivalent > MySQL, MariaDB, Percona Server, or equivalentDatabase Host [127.0.0.1]: Database Name: drupal8_demo Database User: rootDatabase Pass: Database Prefix: Database Port [3306]: Provide your Drupal site name [Drupal 8 Site Install]: Drupal8 DemoProvide your Drupal site mail [[email protected]]: Provide your Drupal administrator account name [admin]: Provide your Drupal administrator account mail [[email protected]]: Provide your Drupal administrator account password: [] Starting Drupal 8 install process[] Your Drupal 8 installation was completed sucessfully
PŘÍKAZY PRO DEBUGOVÁNÍ$ drupal config:debug # Výpis konfigurace$ drupal container:debug # Seznam služeb$ drupal cron:debug # Seznam modulů s úlohami pro cron$ drupal database:log:debug$ drupal migrate:debug # Seznam dostupných migrací$ drupal module:debug # Seznam dostupných modulů$ drupal multisite:debug $ drupal rest:debug # Seznam REST zdrojů$ drupal router:debug # Seznam rout$ drupal site:debug # Seznam lokálních i remote webů$ drupal update:debug$ drupal views:debug
PŘIDÁNÍ WEBROFILERU A LIŠTY$ drupal module:download webprofiler
[+] Getting releases for module webprofilerPlease select your favorite release [8.x2.0rc3 ] 8.x2.0rc3 [8.x2.0rc2 ] 8.x2.0rc2 [8.x2.0rc1 ] 8.x2.0rc1 [8.x2.0beta16 ] 8.x2.0beta16 [8.x2.0beta15 ] 8.x2.0beta15 [8.x1.1beta15 ] 8.x1.1beta15 [8.x1.1beta13 ] 8.x1.1beta13 ... > 8.x2.0rc3[] Downloading module webprofiler release 8.x2.0rc3[] Module webprofiler version 8.x2.0rc3 was downloaded successfully
$ drupal module:install webprofiler
KONFIGURACE WEBPROFILERU$ drupal config:edit webprofiler.config
purge_on_cache_clear: truestorage: profiler.database_storageexclude: "/contextual/*\r\n/toolbar/*\r\n/edit/*\r\n*.js\r\n*.css"ide_link: 'subl://open?url=file://@file&line=@line'active_toolbar_items: assets: assets blocks: blocks cache: cache config: config database: database events: events drupal_extension: drupal_extension forms: '0' http: '0' php_config: php_config performance_timing: performance_timing request: request routing: routing services: services state: state theme: theme time: time translations: translations user: user views: views mail: '0'query_sort: sourcequery_highlight: 5langcode: cs
UŽITEČNÉ PŘÍKAZYZměna módu aplikace
$ drupal site:mode prod$ drupal site:mode dev
Stránka údržby$ drupal site:maintenance on$ drupal site:maintenance off
Export a import nastavení$ drupal config:export$ drupal config:import
VLASTNÍ MODUL$ drupal generate:module
Welcome to the Drupal module generator
Enter the new module name: demoEnter the module machine name [demo]: Enter the module Path [/modules/custom]: Enter module description [My Awesome Module]: My Demo moduleEnter package name [Other]: Enter Drupal Core version [8.x]: Define module as feature [no]? Do you want to add a composer.json file to your module [no]? yesWould you like to add module dependencies [no]? Do you confirm generation [yes]?
Generated or updated files
Site path: /home/hason/Projekty/drupaltest/demo1 modules/custom/demo/demo.info.yml2 modules/custom/demo/demo.module3 modules/custom/demo/composer.json
$ drupal module:install demo
VLASTNÍ CONTROLLER$ drupal generate:controller
Welcome to the Drupal Controller generator
Enter the module name: demoEnter the Controller class name [DefaultController]: HelloControllerController title: HelloEnter the action method name [index]: helloEnter the route path [demo/hello/param_1/param_2]: demo/hello/name Controller title (empty to start with code generation): Do you want to generate a unit test class [yes]? noDo you want to load services from the container [no]? yes
Type the service name or use keyup or keydown.This is optional, press enter to continue
Enter your service: twigEnter your service: Do you confirm generation [yes]?
Generated or updated files
Site path: /home/hason/Projekty/drupaltest/demo1 modules/custom/demo/src/Controller/HelloController.php2 modules/custom/demo/demo.routing.yml
[+] Rebuilding routes, wait a moment please[+] Done rebuilding route(s).
VLASTNÍ CONTROLLER<?php// modules/custom/demo/src/Controller/HelloController.php
namespace Drupal\demo\Controller;
use Drupal\Component\Utility\Html;use Drupal\Core\Controller\ControllerBase;use Drupal\Core\Template\TwigEnvironment;use Symfony\Component\DependencyInjection\ContainerInterface;
class HelloController extends ControllerBase
protected $twig;
public function __construct(TwigEnvironment $twig) $this>twig = $twig;
public static function create(ContainerInterface $container) return new static( $container>get('twig') );
public function hello($name) return [ '#type' => 'markup', '#markup' => sprintf('Hello %s!', Html::escape($name)), ];
VLASTNÍ CONTROLLER A ŠABLONA// modules/custom/demo/src/Controller/HelloController.php//...
use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpFoundation\Response;
class HelloController extends ControllerBase // ...
public function hello(Request $request, $name) return new Response( $this>twig>render('@demo/hello.html.twig', ['name' => $name]) ); // ...
# modules/custom/demo/templates/hello.html.twig #
Hello name !
A TO UŽ JSME V SYMFONY!
https://github.com/hasonhttps://twitter.com/@hasonmhttps://www.webuni.cz