@opdavies Senior Drupal Developer at Former Drupal Association employee Symfony hobbyist Drupal Bristol organiser, PHPSW and DrupalCamp Bristol co-organiser First PHP conference! Appnovation Technologies
About Drupal Drupal is an open source, PHP content management system 16 years old Drupal 8 was released in November 2015 Non-BC changes between major versions Mostly procedural code prior to D8 Drupalisms
Hooks / / h e l l o . m o d u l e / * * * I m p l e m e n t s h o o k _ m e n u ( ) * / f u n c t i o n h e l l o _ m e n u ( ) { $ i t e m s [ ' h e l l o - w o r l d ' ] = a r r a y ( . . . ) ; r e t u r n $ i t e m s ; }
Theme functions $ i t e m s [ l ( ' F o o ' , ' f o o ' ) , l ( ' B a r ' , ' b a r ' ) , ] ; r e t u r n t h e m e ( ' i t e m _ l i s t ' , [ ' i t e m s ' = > $ i t e m s ] ) ; < u l c l a s s = " i t e m - l i s t " > < l i > < a h r e f = " f o o " > F o o < / a > < / l i > < l i > < a h r e f = " b a r " > B a r < / a > < / l i > < / u l >
Symfony Core developed using Symfony components Minimum PHP version requirement PHP code in classes No more functions (almost) Namespaces PSR-0 PSR-4 Autoloading Dependency injection Full test coverage Consistency!
YAML example.info (D7) n a m e = E x a m p l e c o r e = 7 . x p a c k a g e = C u s t o m d e p e n d e n c i e s [ ] = e n t i t y f i l e s [ ] = a . i n c f i l e s [ ] = b . i n c example.info.yml (D8) n a m e : E x a m p l e t y p e : m o d u l e c o r e : 8 . x p a c k a g e : C u s t o m d e p e n d e n c i e s : - e n t i t y
Routing (D7) hello.module f u n c t i o n h e l l o _ m e n u ( ) { $ i t e m s [ ' h e l l o - w o r l d ' ] = [ ' t i t l e ' = > ' H e l l o , P H P S C ' , ' p a g e c a l l b a c k ' = > ' h e l l o _ p a g e _ c a l l b a c k ' , ' a c c e s s a r g u m e n t s ' = > [ ' a c c e s s c o n t e n t ' ] , ] ; r e t u r n $ i t e m s ; }
Routing (D8) hello.routing.yml h e l l o . v i e w : p a t h : / h e l l o - w o r l d d e f a u l t s : _ t i t l e : ' H e l l o , P H P S C ' _ c o n t r o l l e r : ' \ D r u p a l \ h e l l o \ C o n t r o l l e r \ P a g e C o n t r o l l e r : : h e l l o V i e w '
Composer Drupal 8 using Composer for dependency management and autoloading Better Composer support since 8.1 Composer integration on Drupal.org Drupal Composer projectroject template Project template Drupal Packagist
Drupal via Composer " r e p o s i t o r i e s " : [ { " t y p e " : " c o m p o s e r " , " u r l " : " h t t p s : / / p a c k a g e s . d r u p a l . o r g / 8 " } ] , r e q u i r e : { " d r u p a l / c o r e " : " ~ 8 . 0 " } , . . . https://github.com/platformsh/platformsh-example-drupal/blob/8.x/composer.json
Contrib - Symfony WebPro ler Bundle as a Drupal 8 module - adds a GUI for Composer dependencies - PSR-4 support for Drupal 7 Web Pro ler Composer Manager xautoload
Drupal Console A CLI tool for generating Drupal code and interacting with Drupal 8 websites Based on Symfony Console component PSR-2 coding style, outputs Drupal code style http://drupalconsole.com