SlideShare a Scribd company logo
1 of 53
Zephir
A WIND OF CHANGE FOR WRITING PHP EXTENSIONS
What is Zephir?
Zephir – Zend Engine PHP Intermediate.
A high-level domain-specific language (DSL) that simplifies
the creation and maintain-ability of native C extensions for
PHP.
Developed by the team behind Phalcon, the PHP CMS
written in C.
What is Zephir?
The creators of Zephir actually pronounce it “zaefire”.
(/ˈzäfī(-ə)r/)
But I still pronounce it “Zephir” (/ˈzef.ər/)
The Zephir Language is an open source project licensed
under an MIT license.
Zephir is written in PHP.
What is Zephir?
In a nutshell
Zephir makes it easy for high-level developers write low-level PHP
Extensions.
Writing a PHP Extension
https://wiki.php.net/internals/references
http://www.phpinternalsbook.com/
http://www.amazon.com/Extending-Embedding-PHP-Sara-Golemon/dp/067232704X
Why might I write an Extension?
Native C Extensions to PHP can typically execute faster than
raw PHP code.
The ability to use native C datatypes in an Extension may
help save memory usage.
Deploying an Extension allows you to keep the source of
your code closed.
Why might I write an Extension?
If a class is heavily IO bound, or requires the allocation/
deallocation of large amounts of memory, then you will
probably not gain any performance benefits.
Unless you can take advantage of the native C datatypes
internally in the code, then you will probably not gain any
memory benefits.
Why might I write an Extension?
Performance comparison
HHVM vs Zephir vs PHP
https://www.simonholywell.com/post/2014/02/hhvm-vs-zephir-vs-php-the-
showdown/
https://www.simonholywell.com/static/files/2014-02-28/index.html
Simon Holywell
Australian Zend certified Development Director at Mosaic in Brighton, UK
What is Zephir?
http://zephir-lang.com/
https://github.com/phalcon/zephir
Zephir – Installation (Ubuntu)
Requirements
◦gcc >= 4.x/clang >= 3.x
◦re2c 0.13 or later
◦gnu make 3.81 or later
◦autoconf 2.31 or later
◦automake 1.14 or later
◦libpcre3
◦php development headers and tools
Zephir – Installation (Ubuntu)
$ sudo apt-get update
$ sudo apt-get install -y python-software-properties
$ sudo apt-get install -y curl
$ sudo apt-get install -y git gcc make re2c libpcre3-dev
$ sudo add-apt-repository ppa:ondrej/php5-5.6
$ sudo apt-get update
$ sudo apt-get install -y php5 dh-make-php php5-dev
$ sudo apt-get install -y php5-curl php5-gd php5-gmp php5-mcrypt 
php5-intl php5-cli
Zephir – Installation (Ubuntu)
$ php –v
PHP 5.6.13-1+deb.sury.org~precise+3 (cli)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
$ phpize –v
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
Zephir – Installation (Ubuntu)
$ git clone https://github.com/phalcon/zephir
$ cd zephir
$ ./install-json
$ ./install -c
$ cd ..
$ zephir version
0.8.0a
Zephir – Important Commands
$ zephir init [namespace]
Initialises a Zephir extension
$ zephir compile
Compiles a Zephir extension
$ zephir fullclean
Cleans the object files generated in compilation
$ zephir install
Installs the extension (requires root access)
$ zephir help
Displays help
Zephir – First Steps
$ zephir init helloworld
$ ls helloworld
helloworld/
ext/
helloworld/ ## Our zephir .zep files go here
config.json ## Configuration file for our extension
Zephir – First Steps
$ cd helloworld
$ cat config.json
…
"namespace": "helloworld",
"name": "helloworld",
"description": "Hello World Extension",
"author": "Mark Baker",
"version": "0.0.1",
"verbose": false,
"requires": {
"extensions": []
}
Zephir – First Steps
Organise your code into files and namespaces
Uses Case-Sensitive file/folder names
Always use lower-case for file/folder names
Every file must contain one (and only one) class
Only OOP Code, no new PHP functions
Class names can be mixed-case
Classes must be namespaced
Top-level Namespace should match the namespace defined in config.json
but may be mixed-case
Zephir – First Steps
$ cd helloworld
$ cat greetings.zep
namespace HelloWorld;
class greetings {
public function english() {
// Variables must be defined before they can be used
var greeting;
// "let" is used to assign values to a variable
let greeting = "Hello World";
echo greeting, PHP_EOL;
}
}
Zephir – First Steps
$ cd ..
$ zephir compile
helloworld/
ext/
/helloworld ## zephir generates C source code here
/modules ## zephir builds the PHP Extension here
helloworld/
compile-errors.log
compile.log
config.json
Zephir – First Steps
$ zephir install
or
$ sudo cp ext/modules/helloworld.so /usr/lib/php5/20131226/helloworld.so
$ sudo nano /etc/php5/cli/php.ini
extension=helloworld.so
php -m
Zephir – First Steps
$ php -i | grep -m 2 -A 4 helloworld
helloworld
Hello World Extension
helloworld => enabled
Author => Mark Baker
Version => 0.0.1
Build Date => Sep 27 2015 08:57:19
Powered by Zephir => Version 0.8.0a
Zephir – First Steps
$ cat helloworld.php
<?php
$instance = new HelloWorldgreetings();
$instance->english();
$ php helloworld.php
Hello World
Zephir – Variables
Variable names don’t begin with a $
Variables must be pre-defined/declared
var stringVar = "hello", boolVar = true, intVar = 1.0;
int answer = 42, question = 1;
PHP scope rules apply
Global variables don’t exist in Zephir (except that SuperGlobals can be accessed)
let requestMethod = _SERVER["REQUEST_METHOD"];
Zephir – Variables
Variable variables do not exist in Zephir
But they can be “simulated”
//Set variable $name in PHP
let {"name"} = "hello";
//Set variable $price in PHP
let name = "price";
let {name} = 10.2;
Zephir – Variable Types
Dynamic Typed Variables
Like PHP variables, and can change datatype between the different variable
types supported by PHP
Declared with the keyword “var”
var name = "Mark";
Static Typed Variables
A subset of C-Datatypes
boolean, int, uint, char, uchar, long, ulong, string, array
Can’t change datatype once declared
Declared with the appropriate datatype name
uint counter = 1;
Zephir – Strings
String literals (dynamic var, static string) must be wrapped in double quotes
var name = "Mark Baker";
Character literals (static char, static uchar) must be wrapped in single quotes
char initial = 'M';
Strings in Zephir do not support variable interpolation/parsing; use
concatenation instead:
let forename = "Mark";
let surname = "Baker";
let fullName = forename . " " . surname;
Zephir – Arrays
Array variables can be declared using the keywords “var” or “array”:
var a = []; // dynamic variable
array b = []; // static array variable
As in PHP, keys can only be string or integer values
Syntax is slightly different:
let elements = [
"foo": "bar", // Use of : rather than =>
"bar": "foo" // No trailing , permitted
];
Zephir – Control Structures
public function compare(a, b) {
if a < b {
return -1;
} elseif a > b {
return 1;
}
return 0;
}
Brackets around the evaluated condition are optional
Zephir – Control Structures
let counter = 0;
while counter < 10 {
echo counter, PHP_EOL;
let counter += 1;
}
Brackets around the evaluated condition are optional
Zephir – Control Structures
let n = 10;
loop {
let n -= 2;
if n == 0 { break; }
echo n, PHP_EOL;
}
Zephir – Control Structures
let items = ["a": 1, "b": 2, "c": 3, "d": 4];
for key, value in items {
echo key, " : ", value, PHP_EOL;
}
for key, value in reverse items {
echo key, " : ", value, PHP_EOL;
}
Zephir – Control Structures
string fullName = "Mark Baker"; char character;
for character in fullName {
echo character , PHP_EOL;
}
for character in reverse fullName {
echo character , PHP_EOL;
}
Zephir – Control Structures
let items = ["a": 1, "b": 2, "c": 3, "d": 4];
for key, _ in items {
echo key, PHP_EOL;
}
The value element in the for loop doesn’t need to be declared
Zephir – Exceptions
try {
// exceptions can be thrown here
if (firstCase) {
throw new RuntimeException("This is an exception");
} else {
throw "Untyped Exception";
}
} catch RuntimeException|Exception, e {
// handle exception
echo e->getMessage();
}
Special Features of Zephir
Type Hints
Object/Interface Type Hints
public function injectFilter(<AppFilterInterface> filter)
{
//...
}
Similar to the existing type hints in PHP, although notice the syntax
differences
Special Features of Zephir
Type Hints
“Scalar” Type Hints
public function filterText(string text, boolean escape=false)
{
//...
}
Allows “compatible” types, e.g.
this->filterText(1234, 0);
Will try to convert the data passed to the type-hinted datatype
Special Features of Zephir
Type Hints
Strict Scalar Hints
public function filterText(string! text, boolean escape=false)
{
//...
}
this->filterText(1234, 0);
Will throw an Exception
Special Features of Zephir
Return Type Hints
public function getClassFromFactory() -> <AppMyInterface> {
//...
}
Similar to the return type hints introduced in PHP 7, although notice the
syntax differences
function isValidStatusCode(int $statusCode): bool {
//...
}
Special Features of Zephir
Read-Only Arguments
public function filterText(const string text, boolean escape=false)
{
//...
}
Used for compiler optimisations
Special Features of Zephir
Named Arguments
public function crop(width = 600, height = 400) {
//...
}
this->crop(height: 200);
this->crop(height: 300, width: 400);
Adds a slight performance overhead
Zephir – Pitfalls
Silent compilation failures
$ zephir compile
helloworld/
ext/
/helloworld ## zephir generates C source code here
/modules ## zephir builds the PHP Extension here
helloworld/
compile-errors.log ## Always check this file
compile.log
config.json
Zephir – Pitfalls
Unsupported Features of PHP
Array Dereferencing
Callbacks can’t use “use”
Zephir – Pitfalls
Bad assumptions from lazy PHP practises
In PHP, a pass-by-reference variable in an expression like
$validComplex = preg_match('/^...$/ui', $complexNumber, $complexParts);
will automatically created $complexParts if it doesn't exist;
but Zephir won't do this, so you need to explicitly create it in advance
var complexParts;
let validComplex = preg_match("/^....$/ui", complexNumber, complexParts);
Zephir – Pitfalls
Overly-Complex or Ambiguous Syntax
An expression like
if (!is_object($complex) || !$complex instanceof Complex) { … }
Might logically be translated to Zephir as
if !is_object(complex) || !complex instanceof Complex { … }
but Zephir has a different precedence to PHP for instanceof, so you
need to do
if !is_object(complex) || !(complex instanceof Complex) { … }
otherwise it executes !complex and then tests the result of that (always
a boolean) for instanceOf Complex
cf. https://github.com/phalcon/zephir/issues/277
Zephir – Utilities and Helpers
PHP to Zephir
https://github.com/fezfez/php-to-zephir
Zephir – Utilities and Helpers
$ zephir init helloworld
$ cd helloworld
$ /home/vagrant/vendor/bin/php-to-zephir phpToZephir:convertDir 
<path to PHP source code>
Zephir – Testing
Zephir – Testing
$ cd helloworld
helloworld/
ext/
/helloworld
/modules
run-tests.php ## PHP Test execution script
helloworld/
compile-errors.log
compile.log
config.json
Zephir – Testing
$ cd ext/modules
$ php run-tests.php *.phpt <directory with test files>
$ php run-tests.php --help
Useful Option
-c <filename> ## Custom php.ini file to be used
Zephir – Testing
$ cat helloWorldTest001.phpt
--TEST--
Test Hello World display using helloworld extension
--FILE--
<?php
$instance = new HelloWorldgreetings();
$instance->english();
--EXPECT--
Hello World
Zephir – Testing
$ php run-tests.php *.phpt <directory with test files>
…
=====================================================================
Running selected tests.
PASS Test Hello World display using helloworld extension
[/srv/phpnw2015/helloworld/tests/helloWorldTest-001.phpt]
=====================================================================
Number of tests : 1 1
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 1 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken : 0 seconds
=====================================================================
Zephir – Testing
https://qa.php.net/write-test.php
https://qa.php.net/phpt_details.php
Useful Zephir Links
Zephir Documentation
http://docs.zephir-lang.com/
Zephir Blog
http://blog.zephir-lang.com/

More Related Content

What's hot

Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPGuilherme Blanco
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)Win Yu
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11Combell NV
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...King Foo
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11Combell NV
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015Colin O'Dell
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021Ayesh Karunaratne
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationKirill Chebunin
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodeSWIFTotter Solutions
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Puppet
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principlesPerl Careers
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckrICh morrow
 

What's hot (20)

Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHPDoctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11
 
PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015PHP 7 Crash Course - php[world] 2015
PHP 7 Crash Course - php[world] 2015
 
PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
 
Rich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 ApplicationRich Model And Layered Architecture in SF2 Application
Rich Model And Layered Architecture in SF2 Application
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better Code
 
Spl in the wild
Spl in the wildSpl in the wild
Spl in the wild
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 

Viewers also liked

Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"Fwdays
 
Hexagonal architecture message-oriented software design
Hexagonal architecture   message-oriented software designHexagonal architecture   message-oriented software design
Hexagonal architecture message-oriented software designMatthias Noback
 
SPL - The Undiscovered Library - PHPBarcelona 2015
SPL - The Undiscovered Library - PHPBarcelona 2015SPL - The Undiscovered Library - PHPBarcelona 2015
SPL - The Undiscovered Library - PHPBarcelona 2015Mark Baker
 
Are you a good scout? - PHPNW15 Unconf
Are you a good scout? - PHPNW15 UnconfAre you a good scout? - PHPNW15 Unconf
Are you a good scout? - PHPNW15 Unconfphpboyscout
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHPRafael Dohms
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I thinkWim Godden
 
Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015Joe Ferguson
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Chris Tankersley
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 
Building Your API for Longevity
Building Your API for LongevityBuilding Your API for Longevity
Building Your API for LongevityMuleSoft
 
Giving birth to an ElePHPant
Giving birth to an ElePHPantGiving birth to an ElePHPant
Giving birth to an ElePHPantMark Baker
 
Getting your open source company to contribution
Getting your open source company to contributionGetting your open source company to contribution
Getting your open source company to contributionAsavin Wattanajantra
 
Refactorizando Pccomponentes.com con Symfony
Refactorizando Pccomponentes.com con SymfonyRefactorizando Pccomponentes.com con Symfony
Refactorizando Pccomponentes.com con SymfonyMario Marín
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsEric Hogue
 

Viewers also liked (20)

The IoC Hydra
The IoC HydraThe IoC Hydra
The IoC Hydra
 
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
Andres Gutierrez "Phalcon 3.0, Zephir & PHP7"
 
Hexagonal architecture message-oriented software design
Hexagonal architecture   message-oriented software designHexagonal architecture   message-oriented software design
Hexagonal architecture message-oriented software design
 
SPL - The Undiscovered Library - PHPBarcelona 2015
SPL - The Undiscovered Library - PHPBarcelona 2015SPL - The Undiscovered Library - PHPBarcelona 2015
SPL - The Undiscovered Library - PHPBarcelona 2015
 
Your code are my tests
Your code are my testsYour code are my tests
Your code are my tests
 
TDD: Team-Driven Development
TDD: Team-Driven DevelopmentTDD: Team-Driven Development
TDD: Team-Driven Development
 
Are you a good scout? - PHPNW15 Unconf
Are you a good scout? - PHPNW15 UnconfAre you a good scout? - PHPNW15 Unconf
Are you a good scout? - PHPNW15 Unconf
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHP
 
My app is secure... I think
My app is secure... I thinkMy app is secure... I think
My app is secure... I think
 
Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015Secure Form Processing and Protection - Sunshine PHP 2015
Secure Form Processing and Protection - Sunshine PHP 2015
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Building Your API for Longevity
Building Your API for LongevityBuilding Your API for Longevity
Building Your API for Longevity
 
Giving birth to an ElePHPant
Giving birth to an ElePHPantGiving birth to an ElePHPant
Giving birth to an ElePHPant
 
Getting your open source company to contribution
Getting your open source company to contributionGetting your open source company to contribution
Getting your open source company to contribution
 
Dockerize All The Things
Dockerize All The ThingsDockerize All The Things
Dockerize All The Things
 
Refactorizando Pccomponentes.com con Symfony
Refactorizando Pccomponentes.com con SymfonyRefactorizando Pccomponentes.com con Symfony
Refactorizando Pccomponentes.com con Symfony
 
Introduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with JenkinsIntroduction to Continuous Integration with Jenkins
Introduction to Continuous Integration with Jenkins
 

Similar to Zephir - A Wind of Change for writing PHP extensions

The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4Wim Godden
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and coweltling
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and coPierre Joye
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshopjulien pauli
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7ZendVN
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5Wim Godden
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.pptJamers2
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptechQuang Anh Le
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extensionNguyen Duc Phu
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extensionVõ Duy Tuấn
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshopjulien pauli
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Vyacheslav Matyukhin
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 

Similar to Zephir - A Wind of Change for writing PHP extensions (20)

The why and how of moving to php 5.4
The why and how of moving to php 5.4The why and how of moving to php 5.4
The why and how of moving to php 5.4
 
Php7 HHVM and co
Php7 HHVM and coPhp7 HHVM and co
Php7 HHVM and co
 
Php7 hhvm and co
Php7 hhvm and coPhp7 hhvm and co
Php7 hhvm and co
 
Php7 extensions workshop
Php7 extensions workshopPhp7 extensions workshop
Php7 extensions workshop
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
PHP
PHPPHP
PHP
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
PHP-03-Functions.ppt
PHP-03-Functions.pptPHP-03-Functions.ppt
PHP-03-Functions.ppt
 
3. build your own php extension ai ti aptech
3. build your own php extension   ai ti aptech3. build your own php extension   ai ti aptech
3. build your own php extension ai ti aptech
 
07 build your-own_php_extension
07 build your-own_php_extension07 build your-own_php_extension
07 build your-own_php_extension
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
Start using PHP 7
Start using PHP 7Start using PHP 7
Start using PHP 7
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)
 
Migrating to PHP 7
Migrating to PHP 7Migrating to PHP 7
Migrating to PHP 7
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
PHP 7
PHP 7PHP 7
PHP 7
 

More from Mark Baker

Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsMark Baker
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to ProductionMark Baker
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to ProductionMark Baker
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to ProductionMark Baker
 
A Brief History of Elephpants
A Brief History of ElephpantsA Brief History of Elephpants
A Brief History of ElephpantsMark Baker
 
Aspects of love slideshare
Aspects of love slideshareAspects of love slideshare
Aspects of love slideshareMark Baker
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Mark Baker
 
A Brief History of ElePHPants
A Brief History of ElePHPantsA Brief History of ElePHPants
A Brief History of ElePHPantsMark Baker
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding HorrorsMark Baker
 
Anonymous classes2
Anonymous classes2Anonymous classes2
Anonymous classes2Mark Baker
 
Testing the Untestable
Testing the UntestableTesting the Untestable
Testing the UntestableMark Baker
 
Anonymous Classes: Behind the Mask
Anonymous Classes: Behind the MaskAnonymous Classes: Behind the Mask
Anonymous Classes: Behind the MaskMark Baker
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Mark Baker
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding HorrorsMark Baker
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Mark Baker
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsMark Baker
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsMark Baker
 
Flying under the radar
Flying under the radarFlying under the radar
Flying under the radarMark Baker
 

More from Mark Baker (20)

Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Looping the Loop with SPL Iterators
Looping the Loop with SPL IteratorsLooping the Loop with SPL Iterators
Looping the Loop with SPL Iterators
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to Production
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to Production
 
Deploying Straight to Production
Deploying Straight to ProductionDeploying Straight to Production
Deploying Straight to Production
 
A Brief History of Elephpants
A Brief History of ElephpantsA Brief History of Elephpants
A Brief History of Elephpants
 
Aspects of love slideshare
Aspects of love slideshareAspects of love slideshare
Aspects of love slideshare
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?
 
A Brief History of ElePHPants
A Brief History of ElePHPantsA Brief History of ElePHPants
A Brief History of ElePHPants
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Anonymous classes2
Anonymous classes2Anonymous classes2
Anonymous classes2
 
Testing the Untestable
Testing the UntestableTesting the Untestable
Testing the Untestable
 
Anonymous Classes: Behind the Mask
Anonymous Classes: Behind the MaskAnonymous Classes: Behind the Mask
Anonymous Classes: Behind the Mask
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?
 
Coding Horrors
Coding HorrorsCoding Horrors
Coding Horrors
 
Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?Does the SPL still have any relevance in the Brave New World of PHP7?
Does the SPL still have any relevance in the Brave New World of PHP7?
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
A Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP GeneratorsA Functional Guide to Cat Herding with PHP Generators
A Functional Guide to Cat Herding with PHP Generators
 
Flying under the radar
Flying under the radarFlying under the radar
Flying under the radar
 

Recently uploaded

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 

Recently uploaded (20)

Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 

Zephir - A Wind of Change for writing PHP extensions

  • 1. Zephir A WIND OF CHANGE FOR WRITING PHP EXTENSIONS
  • 2. What is Zephir? Zephir – Zend Engine PHP Intermediate. A high-level domain-specific language (DSL) that simplifies the creation and maintain-ability of native C extensions for PHP. Developed by the team behind Phalcon, the PHP CMS written in C.
  • 3. What is Zephir? The creators of Zephir actually pronounce it “zaefire”. (/ˈzäfī(-ə)r/) But I still pronounce it “Zephir” (/ˈzef.ər/) The Zephir Language is an open source project licensed under an MIT license. Zephir is written in PHP.
  • 4. What is Zephir? In a nutshell Zephir makes it easy for high-level developers write low-level PHP Extensions.
  • 5. Writing a PHP Extension https://wiki.php.net/internals/references http://www.phpinternalsbook.com/ http://www.amazon.com/Extending-Embedding-PHP-Sara-Golemon/dp/067232704X
  • 6. Why might I write an Extension? Native C Extensions to PHP can typically execute faster than raw PHP code. The ability to use native C datatypes in an Extension may help save memory usage. Deploying an Extension allows you to keep the source of your code closed.
  • 7. Why might I write an Extension? If a class is heavily IO bound, or requires the allocation/ deallocation of large amounts of memory, then you will probably not gain any performance benefits. Unless you can take advantage of the native C datatypes internally in the code, then you will probably not gain any memory benefits.
  • 8. Why might I write an Extension? Performance comparison HHVM vs Zephir vs PHP https://www.simonholywell.com/post/2014/02/hhvm-vs-zephir-vs-php-the- showdown/ https://www.simonholywell.com/static/files/2014-02-28/index.html Simon Holywell Australian Zend certified Development Director at Mosaic in Brighton, UK
  • 10. Zephir – Installation (Ubuntu) Requirements ◦gcc >= 4.x/clang >= 3.x ◦re2c 0.13 or later ◦gnu make 3.81 or later ◦autoconf 2.31 or later ◦automake 1.14 or later ◦libpcre3 ◦php development headers and tools
  • 11. Zephir – Installation (Ubuntu) $ sudo apt-get update $ sudo apt-get install -y python-software-properties $ sudo apt-get install -y curl $ sudo apt-get install -y git gcc make re2c libpcre3-dev $ sudo add-apt-repository ppa:ondrej/php5-5.6 $ sudo apt-get update $ sudo apt-get install -y php5 dh-make-php php5-dev $ sudo apt-get install -y php5-curl php5-gd php5-gmp php5-mcrypt php5-intl php5-cli
  • 12. Zephir – Installation (Ubuntu) $ php –v PHP 5.6.13-1+deb.sury.org~precise+3 (cli) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies $ phpize –v Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
  • 13. Zephir – Installation (Ubuntu) $ git clone https://github.com/phalcon/zephir $ cd zephir $ ./install-json $ ./install -c $ cd .. $ zephir version 0.8.0a
  • 14. Zephir – Important Commands $ zephir init [namespace] Initialises a Zephir extension $ zephir compile Compiles a Zephir extension $ zephir fullclean Cleans the object files generated in compilation $ zephir install Installs the extension (requires root access) $ zephir help Displays help
  • 15. Zephir – First Steps $ zephir init helloworld $ ls helloworld helloworld/ ext/ helloworld/ ## Our zephir .zep files go here config.json ## Configuration file for our extension
  • 16. Zephir – First Steps $ cd helloworld $ cat config.json … "namespace": "helloworld", "name": "helloworld", "description": "Hello World Extension", "author": "Mark Baker", "version": "0.0.1", "verbose": false, "requires": { "extensions": [] }
  • 17. Zephir – First Steps Organise your code into files and namespaces Uses Case-Sensitive file/folder names Always use lower-case for file/folder names Every file must contain one (and only one) class Only OOP Code, no new PHP functions Class names can be mixed-case Classes must be namespaced Top-level Namespace should match the namespace defined in config.json but may be mixed-case
  • 18. Zephir – First Steps $ cd helloworld $ cat greetings.zep namespace HelloWorld; class greetings { public function english() { // Variables must be defined before they can be used var greeting; // "let" is used to assign values to a variable let greeting = "Hello World"; echo greeting, PHP_EOL; } }
  • 19. Zephir – First Steps $ cd .. $ zephir compile helloworld/ ext/ /helloworld ## zephir generates C source code here /modules ## zephir builds the PHP Extension here helloworld/ compile-errors.log compile.log config.json
  • 20. Zephir – First Steps $ zephir install or $ sudo cp ext/modules/helloworld.so /usr/lib/php5/20131226/helloworld.so $ sudo nano /etc/php5/cli/php.ini extension=helloworld.so php -m
  • 21. Zephir – First Steps $ php -i | grep -m 2 -A 4 helloworld helloworld Hello World Extension helloworld => enabled Author => Mark Baker Version => 0.0.1 Build Date => Sep 27 2015 08:57:19 Powered by Zephir => Version 0.8.0a
  • 22. Zephir – First Steps $ cat helloworld.php <?php $instance = new HelloWorldgreetings(); $instance->english(); $ php helloworld.php Hello World
  • 23. Zephir – Variables Variable names don’t begin with a $ Variables must be pre-defined/declared var stringVar = "hello", boolVar = true, intVar = 1.0; int answer = 42, question = 1; PHP scope rules apply Global variables don’t exist in Zephir (except that SuperGlobals can be accessed) let requestMethod = _SERVER["REQUEST_METHOD"];
  • 24. Zephir – Variables Variable variables do not exist in Zephir But they can be “simulated” //Set variable $name in PHP let {"name"} = "hello"; //Set variable $price in PHP let name = "price"; let {name} = 10.2;
  • 25. Zephir – Variable Types Dynamic Typed Variables Like PHP variables, and can change datatype between the different variable types supported by PHP Declared with the keyword “var” var name = "Mark"; Static Typed Variables A subset of C-Datatypes boolean, int, uint, char, uchar, long, ulong, string, array Can’t change datatype once declared Declared with the appropriate datatype name uint counter = 1;
  • 26. Zephir – Strings String literals (dynamic var, static string) must be wrapped in double quotes var name = "Mark Baker"; Character literals (static char, static uchar) must be wrapped in single quotes char initial = 'M'; Strings in Zephir do not support variable interpolation/parsing; use concatenation instead: let forename = "Mark"; let surname = "Baker"; let fullName = forename . " " . surname;
  • 27. Zephir – Arrays Array variables can be declared using the keywords “var” or “array”: var a = []; // dynamic variable array b = []; // static array variable As in PHP, keys can only be string or integer values Syntax is slightly different: let elements = [ "foo": "bar", // Use of : rather than => "bar": "foo" // No trailing , permitted ];
  • 28. Zephir – Control Structures public function compare(a, b) { if a < b { return -1; } elseif a > b { return 1; } return 0; } Brackets around the evaluated condition are optional
  • 29. Zephir – Control Structures let counter = 0; while counter < 10 { echo counter, PHP_EOL; let counter += 1; } Brackets around the evaluated condition are optional
  • 30. Zephir – Control Structures let n = 10; loop { let n -= 2; if n == 0 { break; } echo n, PHP_EOL; }
  • 31. Zephir – Control Structures let items = ["a": 1, "b": 2, "c": 3, "d": 4]; for key, value in items { echo key, " : ", value, PHP_EOL; } for key, value in reverse items { echo key, " : ", value, PHP_EOL; }
  • 32. Zephir – Control Structures string fullName = "Mark Baker"; char character; for character in fullName { echo character , PHP_EOL; } for character in reverse fullName { echo character , PHP_EOL; }
  • 33. Zephir – Control Structures let items = ["a": 1, "b": 2, "c": 3, "d": 4]; for key, _ in items { echo key, PHP_EOL; } The value element in the for loop doesn’t need to be declared
  • 34. Zephir – Exceptions try { // exceptions can be thrown here if (firstCase) { throw new RuntimeException("This is an exception"); } else { throw "Untyped Exception"; } } catch RuntimeException|Exception, e { // handle exception echo e->getMessage(); }
  • 35. Special Features of Zephir Type Hints Object/Interface Type Hints public function injectFilter(<AppFilterInterface> filter) { //... } Similar to the existing type hints in PHP, although notice the syntax differences
  • 36. Special Features of Zephir Type Hints “Scalar” Type Hints public function filterText(string text, boolean escape=false) { //... } Allows “compatible” types, e.g. this->filterText(1234, 0); Will try to convert the data passed to the type-hinted datatype
  • 37. Special Features of Zephir Type Hints Strict Scalar Hints public function filterText(string! text, boolean escape=false) { //... } this->filterText(1234, 0); Will throw an Exception
  • 38. Special Features of Zephir Return Type Hints public function getClassFromFactory() -> <AppMyInterface> { //... } Similar to the return type hints introduced in PHP 7, although notice the syntax differences function isValidStatusCode(int $statusCode): bool { //... }
  • 39. Special Features of Zephir Read-Only Arguments public function filterText(const string text, boolean escape=false) { //... } Used for compiler optimisations
  • 40. Special Features of Zephir Named Arguments public function crop(width = 600, height = 400) { //... } this->crop(height: 200); this->crop(height: 300, width: 400); Adds a slight performance overhead
  • 41. Zephir – Pitfalls Silent compilation failures $ zephir compile helloworld/ ext/ /helloworld ## zephir generates C source code here /modules ## zephir builds the PHP Extension here helloworld/ compile-errors.log ## Always check this file compile.log config.json
  • 42. Zephir – Pitfalls Unsupported Features of PHP Array Dereferencing Callbacks can’t use “use”
  • 43. Zephir – Pitfalls Bad assumptions from lazy PHP practises In PHP, a pass-by-reference variable in an expression like $validComplex = preg_match('/^...$/ui', $complexNumber, $complexParts); will automatically created $complexParts if it doesn't exist; but Zephir won't do this, so you need to explicitly create it in advance var complexParts; let validComplex = preg_match("/^....$/ui", complexNumber, complexParts);
  • 44. Zephir – Pitfalls Overly-Complex or Ambiguous Syntax An expression like if (!is_object($complex) || !$complex instanceof Complex) { … } Might logically be translated to Zephir as if !is_object(complex) || !complex instanceof Complex { … } but Zephir has a different precedence to PHP for instanceof, so you need to do if !is_object(complex) || !(complex instanceof Complex) { … } otherwise it executes !complex and then tests the result of that (always a boolean) for instanceOf Complex cf. https://github.com/phalcon/zephir/issues/277
  • 45. Zephir – Utilities and Helpers PHP to Zephir https://github.com/fezfez/php-to-zephir
  • 46. Zephir – Utilities and Helpers $ zephir init helloworld $ cd helloworld $ /home/vagrant/vendor/bin/php-to-zephir phpToZephir:convertDir <path to PHP source code>
  • 48. Zephir – Testing $ cd helloworld helloworld/ ext/ /helloworld /modules run-tests.php ## PHP Test execution script helloworld/ compile-errors.log compile.log config.json
  • 49. Zephir – Testing $ cd ext/modules $ php run-tests.php *.phpt <directory with test files> $ php run-tests.php --help Useful Option -c <filename> ## Custom php.ini file to be used
  • 50. Zephir – Testing $ cat helloWorldTest001.phpt --TEST-- Test Hello World display using helloworld extension --FILE-- <?php $instance = new HelloWorldgreetings(); $instance->english(); --EXPECT-- Hello World
  • 51. Zephir – Testing $ php run-tests.php *.phpt <directory with test files> … ===================================================================== Running selected tests. PASS Test Hello World display using helloworld extension [/srv/phpnw2015/helloworld/tests/helloWorldTest-001.phpt] ===================================================================== Number of tests : 1 1 Tests skipped : 0 ( 0.0%) -------- Tests warned : 0 ( 0.0%) ( 0.0%) Tests failed : 0 ( 0.0%) ( 0.0%) Expected fail : 0 ( 0.0%) ( 0.0%) Tests passed : 1 (100.0%) (100.0%) --------------------------------------------------------------------- Time taken : 0 seconds =====================================================================
  • 53. Useful Zephir Links Zephir Documentation http://docs.zephir-lang.com/ Zephir Blog http://blog.zephir-lang.com/