PantaRei Design
●
Everything Changes and Nothing Remains Still
●
Reinvent Enterprise with Open Source Software and Cloud Computing
●
Hong Kong based FOSS service provider
– Content Management System (CMS) with Drupal
– Cloud Hosting Solution with Amazon Web Services (AWS)
– Team collaborate solution with Atlassian
●
Business Partner with industry leaders
– 2012, AWS Consulting Partner
– 2013, Acquia Partner
– 2013, Atlassian Experts
– 2014, Rackspace Hosting Partner
●
http://pantarei-design.com
Hong Kong Drupal User Group
●
The Hong Kong Drupal User Group are open to everyone with
an interest in Drupal and are a great opportunity to learn more
about what Drupal can do and what folks are building with it.
●
Drupal is a free software package that allows you to easily
organize, manage and publish your content, with an endless
variety of customization.
– Event organizing: http://www.meetup.com/drupalhk
– Technological discussion: https://groups.drupal.org/drupalhk
– Business connection: http://www.linkedin.com/groups/?gid=6644792
– General sharing: https://www.facebook.com/groups/drupalhk
PHP 7.1
●
PHP 7.1 is released on 2016 Dec 01th
●
PHP 7 is up to twice as fast as PHP 5.6
●
PHP 7.1.0 comes with numerous improvements and new features such as
– Nullable types
– Void return type
– Iterable pseudo-type
– Class constant visiblity modifiers
– Square bracket syntax for list() and the ability to specify keys in list()
– Catching multiple exceptions types
– Many more features and changes…
●
http://php.net/archive/2016.php#id2016-12-01-3
Class constant visiblity modifiers
<?php
class Token {
// Constants default to public
const PUBLIC_CONST = 0;
// Constants then also can have a defined visibility
private const PRIVATE_CONST = 0;
protected const PROTECTED_CONST = 0;
public const PUBLIC_CONST_TWO = 0;
//Constants can only have one visibility declaration list
private const FOO = 1, BAR = 2;
}
Square bracket syntax for array
destructuring assignment
<?php
// The two lines in each of the following pairs are equivalent to each other
list($a, $b, $c) = array(1, 2, 3);
[$a, $b, $c] = [1, 2, 3];
list("a" => $a, "b" => $b, "c" => $c) = array("a" => 1, "b" => 2, "c" => 3);
["a" => $a, "b" => $b, "c" => $c] = ["a" => 1, "b" => 2, "c" => 3];
list($a, $b) = array($b, $a);
[$a, $b] = [$b, $a];
PHP-FIG
●
The FIG stands for Framework
Interoperability Group. The name until
recently was “PHP Standards Group” but this
was somewhat inaccurate of the intentions
of the group
●
http://www.php-fig.org/
PSR-4: Autoloader
This PSR describes a specification for autoloading
classes from file paths, e.g.
– Fully Qualified Class Name
●
SymfonyCoreRequest
– Namespace Prefix
●
SymfonyCore
– Base Directory
●
./vendor/Symfony/Core/
– Resulting File Path
●
./vendor/Symfony/Core/Request.php
Composer
●
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.
●
https://getcomposer.org/
Autoloading
For libraries that specify autoload information,
Composer generates a vendor/autoload.php file. You
can simply include this file and you will get autoloading
for free
– require __DIR__ . '/vendor/autoload.php';
– $log = new MonologLogger('name');
– $log->pushHandler(new
MonologHandlerStreamHandler('app.log',
MonologLogger::WARNING));
– $log->addWarning('Foo');
Composer also support PSR-4 autoloading
Symfony 3.2
●
Symfony 3.2 is released on 2016 Nov 30th
●
150+ new features in this releases in total, e.g.
– DX (Experience *Exceptional*) improvements
– Runtime Environment Variables
– Web Debug Toolbar and Profiler Improvements
– CSV and YAML encoders for Serializer
– Cache improvements
– Firewall config class and profiler
– Unicode routing support
●
http://symfony.com/blog/symfony-3-2-0-released
Creating a Page: Route and
Controller
// src/AppBundle/Controller/LuckyController.php
namespace AppBundleController;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SymfonyComponentHttpFoundationResponse;
class LuckyController
{
/**
* @Route("/lucky/number")
*/
public function numberAction()
{
$number = mt_rand(0, 100);
return new Response(
'<html><body>Lucky number: '.$number.'</body></html>'
);
}
}
Drupal 8.2
●
Drupal 8.2.4 is released on 2016 Dec 08th
●
As of Drupal 8.0, Drupal has replaced several fundamental pieces with fresh
components from Symfony2
●
As of Drupal 8.1, Drupal core directly uses Composer to manage dependencies
●
Drupal 8.2 introduce numbers of new features
– Easier to place and configure blocks on pages
– Content moderation now included
– Support for date ranges
– Site building, content authoring, and administrative improvements
– Platform features for web services
●
https://www.drupal.org/project/drupal/releases/8.2.4
Install with Composer
●
composer create-project --stability dev --no-
interaction drustack/framework-standard-
edition:develop drustack
●
https://github.com/drustack/drustack-standa
rd
●
https://github.com/drustack/drustack-stand
ard/blob/develop/composer.json
Generate version information for
`.info.yml` files in YAML format
<?php
// https://github.com/drustack/drustack-standard/blob/develop/src/Composer/ScriptHandler.php
class ScriptHandler
{
/**
* Generate version information for `.info.yml` files in YAML format.
*
* @see _drush_pm_generate_info_yaml_metadata()
*/
protected static function generateInfoYamlMetadata($version, $project, $datestamp)
{
$core = preg_replace('/^([0-9]).*$/', '$1.x', $version);
$date = date('Y-m-d', $datestamp);
$info = <<<METADATA
# Information add by composer on {$date}
core: "{$core}"
project: "{$project}"
version: "{$version}"
datestamp: "{$datestamp}"
METADATA;
return $info;
}
}
I Need More Help!
●
Read documents from Drupal Community
– https://drupal.org/documentation
●
Join Hong Kong Drupal User Group
– Event organizing: http://www.meetup.com/drupalhk
– Technological discussion: https://groups.drupal.org/drupalhk
– Business connection: http://www.linkedin.com/groups/?gid=6644792
– General sharing: https://www.facebook.com/groups/drupalhk
●
Contact us for one (1) month free-trial support service
– http://pantarei-design.com/services/support/#support-service-plans
Address: Unit 326, 3/F, Building 16W
No.16 Science Park West Avenue,
Hong Kong Science Park, Shatin, N.T.
– Phone: +852 3576 3812
– Fax: +852 3753 3663
– Email: sales@pantarei-design.com
– Web: http://pantarei-design.com
Contact us