SlideShare a Scribd company logo
1 PHP
2008/01/22 at
photo by Sara Golemon (flickr.com/photos/pollita/2093670535/)
... (01/05 18:46)
10
PHP
•
•
    »
•
•CodeGen_PECL
   Extension
•
•             PC

• http://phpext.g.hatena.ne.jp/i_
  ogi/20080119/1200758118
PHP   (Extension)
PHP Extension
•C/C++

•PHP
•C           PHP
 »
     (PHP)
•C
             USB
 »libusb
•C
•
•
...
C
Extension       (   )
•mysql         DB
         PHP
 PDO
•imagick

•Xdebug
 PHP
Extension     (       )
PHP                       C

•json (JSON   )
•syck (YAML       )
Extension    (   )
Extension

•SimpleXML
Extension   (   )
•runkit


•operator
 PHP
•
•
    »
    »Sara
    »PHP
Extending and Embedding PHP
• Sara Golemon
• Yahoo! Inc

 runkit

•
•4   5
PHP5
•        ,
    ()
•
•
PHP4 / 5
C
• PHP
•
                5.2
    »5.1

             5.2.2
    »5.2.1

•C
PHP4 is DEAD!!!
•           PHP4

•PHP4
          PHP5
    »
welcome PHP5
•PHP5

 OOP
 »
 »interface
•SPL
•SimpleXML
PHP6
•Unicode

•
•
CodeGen_PECL
       Extension
• CodeGen_PECL   XML
• pecl-gen

•
•
•
CodeGen_PECL      ?
• XML                 PECL

•           XML

• PHP5     PEAR
  PHP4/5
                  4
    »5
ext_skel
• PHP4      ext_skel

•


•
• CodeGen_PECL         IF
• CodeGen_PECL
    »
    » http://www.m-takagi.org/
      docs/php/CodeGen_PECL/
•             PHP
       2
                gihyo.jp
    »
    » http://gihyo.jp/dev/serial/01/php-
      module/0002
CodeGen_PECL
XML(Spec file)
XML                        (    )


•                (     )
• PECL
    »
•
    » C or C++, platform(unix, win,all)
    » --with (header, lib path)
          Extension
    »
XML                  (       )
•       (function)
                         ) code
    »proto(
•
    »MINIT, RINIT
    »MSHUTDOWN, RSHUTDOWN
    »MINFO
• OOP
                PHP4 OOP
    »CodeGen
XML                  (         )
•       (constant)
• ini
•
•

                         XML
•

•       quot;study1quot;
    »
PHP

•             : study1
•       : study1_func()
• ini              : study1.ini
•     : STUDY1_CONSTANT
• hello world
•
  <?php
  function study1_greeting($name = quot;quot;)
  {
    if (strlen($name)) {
      echo quot;Hello, $name!quot;, PHP_EOL;
    } else {
      echo quot;Hello, World!quot;, PHP_EOL;
    }
  }
  ?>
•
     »PHP

    //
    void funcname(void);

    // int             int
    int funcname(int param);

            Example 12.
//    1                              2
//
string funcname(string param1
          [[, string param2], string param3]);
//
int funcname([int param = 42]);
//
int funcname(string param1, ...);
//
object foo funcname(resource bar param1);
          Example 12.
•
•
    »
    »
•
•                       1
•
•

void study1_greeting([string name])
XML(Spec   )
• XML                      <extension>
• name              →
            quot;study1quot;
  »
<?xml version=quot;1.0quot; ?>
<!DOCTYPE extension SYSTEM quot;../extension.dtdquot;>
<extension name=quot;study1quot;>



</extension>
(function            )
• name            →
• <proto>

<function name=quot;study1_greetingquot;>
  <proto>void study1_greeting([string
name])</proto>
  <code>       </code>
  <test>      </test>
</function>
(code   )
•C
•
• PHP
•           : string name
•
    »const char *name
            int name_len
    »
•
    »
• http://www.m-
  takagi.org/docs/php/CodeGen_P
  ECL/x304.html#AEN377
<code>
  if (name_len) {
    //php_printf(quot;Hello, %s%squot;,
                 name, PHP_EOL);
    php_printf(quot;Hello, quot;);
    PHPWRITE(name, name_len);
    php_printf(quot;!%squot;, PHP_EOL);
  } else {
    php_printf(quot;Hello, World!%squot;,
               PHP_EOL);
  }
</code>
(function      test      )
•
• test



<test>
  <code>                </code>
  <result mode=quot;plainquot;>   </result>
</test>
(function        test      )
•


<test>
  <code>study1_greeting();study1_gre
eting(quot;Japanquot;);</code>
  <result mode=quot;plainquot;>Hello, World!
Hello, Japan!</result>
</test>
<?xml version=quot;1.0quot; ?>
<!DOCTYPE extension SYSTEM quot;../extension.dtdquot;>
<extension name=quot;study1quot;>
  <function name=quot;study1_greetingquot;>
    <proto>void study1_greeting([string name])</proto>
    <code>
      if (name_len) {
        //php_printf(quot;Hello, %s%squot;, name, PHP_EOL);
        php_printf(quot;Hello, quot;);
        PHPWRITE(name, name_len);
        php_printf(quot;!%squot;, PHP_EOL);
      } else {
        php_printf(quot;Hello, World!%squot;, PHP_EOL);
      }
    </code>
    <test>
      <code>study1_greeting();study1_greeting(quot;Japanquot;);</code>
      <result mode=quot;plainquot;>Hello, World!
Hello, Japan!</result>
    </test>
  </function>
</extension>
XML

specfile.xml
pecl-gen
pecl-
pecl-gen specfile.xml
OK
$ pecl-gen specfile.xml
Warning: no 'version' attribute given for
<extension>, assuming 1.1.0
       this may lead to compile errors if your
spec file was created for an older version
Creating 'study1' extension in './study1'

Your extension has been created in
directory ./study1.
See ./study1/README and/or ./study1/INSTALL
for further instructions.
study1
             cd

     $ cd study1
•phpize (          )
•./configure
•make
•make test
•sudo make install
phpize
$ phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
./configure
$ ./configure
checking for grep that handles long lines and
-e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate
output... /bin/sed
checking for gcc... gcc
checking for C compiler default output file
name... a.out
...

appending configuration tag quot;F77quot; to libtool
configure: creating ./config.status
config.status: creating config.h
make
$ make
...
----------------------------------------------------------------------
Libraries have been installed in:
   /home/iogiwara/work/extstudy/080122/2/study1/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.
make test
•


•                make test
    php.ini   extension
make test
$ make test
...
=====================================================================
CWD         : /home/iogiwara/work/extstudy/080122/2/study1
PHP         : /usr/bin/php
PHP_SAPI    : cli
PHP_VERSION : 5.2.3-1ubuntu6.3
ZEND_VERSION: 2.2.0
PHP_OS      : Linux - Linux ubuntu-desktop 2.6.22-14-generic #1 ...
INI actual : /etc/php5/cli/php.ini
More .INIs :
Extra dirs :
=====================================================================
Running selected tests.
PASS study1_greeting() function [tests/study1_greeting.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%)
Tests passed    :    1 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken      :    0 seconds
=====================================================================
sudo make install
$ sudo make install
Installing shared extensions:
/usr/lib/php5/20060613+lfs/
•
    »-d extension=○

    »-r


$ php -dextension=study1.so –r
'study1_greeting();'
Hello, World!
CodeGen_PECL
•CodeGen_PECL   ext_skel




•
•
    »http://gihyo.jp/dev/serial/01/php
     -module/0002?page=2
•
•C
• config.m4
第1回PHP拡張勉強会

More Related Content

What's hot

The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
Zend by Rogue Wave Software
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
Wim Godden
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
Federico Damián Lozada Mosto
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
Pierre Joye
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
julien pauli
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
hendrikvb
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
Damien Seguy
 
Perl one-liners
Perl one-linersPerl one-liners
Perl one-liners
daoswald
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
Wim Godden
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
Eric Poe
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHPNat Weerawan
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
Workhorse Computing
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13julien pauli
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
David Sanchez
 
New in php 7
New in php 7New in php 7
New in php 7
Vic Metcalfe
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
Marcus Ramberg
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Shinya Ohyanagi
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
julien pauli
 

What's hot (20)

The new features of PHP 7
The new features of PHP 7The new features of PHP 7
The new features of PHP 7
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
PHP5.5 is Here
PHP5.5 is HerePHP5.5 is Here
PHP5.5 is Here
 
Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
 
Perl one-liners
Perl one-linersPerl one-liners
Perl one-liners
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Get your teeth into Plack
Get your teeth into PlackGet your teeth into Plack
Get your teeth into Plack
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
PHP7 Presentation
PHP7 PresentationPHP7 Presentation
PHP7 Presentation
 
New in php 7
New in php 7New in php 7
New in php 7
 
Mojo as a_client
Mojo as a_clientMojo as a_client
Mojo as a_client
 
Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1Zend Framework Study@Tokyo vol1
Zend Framework Study@Tokyo vol1
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 

Similar to 第1回PHP拡張勉強会

Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009
PHPBelgium
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
Rowan Merewood
 
Api Design
Api DesignApi Design
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008phpbarcelona
 
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
Wim Godden
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
Evaldo Felipe
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
Mohammad Emran Hasan
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial Handouts
Tobias Oetiker
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
毅 吕
 
Test Fest 2009
Test Fest 2009Test Fest 2009
Test Fest 2009
Pierre Joye
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
Giovanni Derks
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
Jason McCreary
 
Introduction into PHP5 (Jeroen van Sluijs)
Introduction into PHP5 (Jeroen van Sluijs)Introduction into PHP5 (Jeroen van Sluijs)
Introduction into PHP5 (Jeroen van Sluijs)Stefan Koopmanschap
 

Similar to 第1回PHP拡張勉強会 (20)

Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009Prepare for PHP Test Fest 2009
Prepare for PHP Test Fest 2009
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Api Design
Api DesignApi Design
Api Design
 
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008Xdebug - Derick Rethans - Barcelona PHP Conference 2008
Xdebug - Derick Rethans - Barcelona PHP Conference 2008
 
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
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
 
Wt unit 4 server side technology-2
Wt unit 4 server side technology-2Wt unit 4 server side technology-2
Wt unit 4 server side technology-2
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial Handouts
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
Ext 0523
Ext 0523Ext 0523
Ext 0523
 
Lca05
Lca05Lca05
Lca05
 
Test Fest 2009
Test Fest 2009Test Fest 2009
Test Fest 2009
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
An introduction to PHP 5.4
An introduction to PHP 5.4An introduction to PHP 5.4
An introduction to PHP 5.4
 
From CakePHP to Laravel
From CakePHP to LaravelFrom CakePHP to Laravel
From CakePHP to Laravel
 
Os Treat
Os TreatOs Treat
Os Treat
 
Introduction into PHP5 (Jeroen van Sluijs)
Introduction into PHP5 (Jeroen van Sluijs)Introduction into PHP5 (Jeroen van Sluijs)
Introduction into PHP5 (Jeroen van Sluijs)
 

More from Ippei Ogiwara

いままで使ってきた携帯電話
いままで使ってきた携帯電話いままで使ってきた携帯電話
いままで使ってきた携帯電話Ippei Ogiwara
 
コミュニティでの動画配信の広がり、それらをささえるツール
コミュニティでの動画配信の広がり、それらをささえるツールコミュニティでの動画配信の広がり、それらをささえるツール
コミュニティでの動画配信の広がり、それらをささえるツールIppei Ogiwara
 
PHP型変換の世界
PHP型変換の世界PHP型変換の世界
PHP型変換の世界
Ippei Ogiwara
 
3分くらいで分かるassert()
3分くらいで分かるassert()3分くらいで分かるassert()
3分くらいで分かるassert()
Ippei Ogiwara
 
テンプレート管理ツール r3
テンプレート管理ツール r3テンプレート管理ツール r3
テンプレート管理ツール r3
Ippei Ogiwara
 

More from Ippei Ogiwara (6)

いままで使ってきた携帯電話
いままで使ってきた携帯電話いままで使ってきた携帯電話
いままで使ってきた携帯電話
 
コミュニティでの動画配信の広がり、それらをささえるツール
コミュニティでの動画配信の広がり、それらをささえるツールコミュニティでの動画配信の広がり、それらをささえるツール
コミュニティでの動画配信の広がり、それらをささえるツール
 
PHP型変換の世界
PHP型変換の世界PHP型変換の世界
PHP型変換の世界
 
3分くらいで分かるassert()
3分くらいで分かるassert()3分くらいで分かるassert()
3分くらいで分かるassert()
 
PHP at Yahoo! JAPAN
PHP at Yahoo! JAPANPHP at Yahoo! JAPAN
PHP at Yahoo! JAPAN
 
テンプレート管理ツール r3
テンプレート管理ツール r3テンプレート管理ツール r3
テンプレート管理ツール r3
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 

第1回PHP拡張勉強会

  • 1. 1 PHP 2008/01/22 at photo by Sara Golemon (flickr.com/photos/pollita/2093670535/)
  • 2.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. 10
  • 10.
  • 11. PHP • • » •
  • 12.
  • 13. •CodeGen_PECL Extension •
  • 14. PC • http://phpext.g.hatena.ne.jp/i_ ogi/20080119/1200758118
  • 15. PHP (Extension)
  • 17. •C PHP » (PHP) •C USB »libusb
  • 19. ... C
  • 20. Extension ( ) •mysql DB PHP PDO •imagick •Xdebug PHP
  • 21. Extension ( ) PHP C •json (JSON ) •syck (YAML )
  • 22. Extension ( ) Extension •SimpleXML
  • 23. Extension ( ) •runkit •operator PHP
  • 24.
  • 25. • • » »Sara »PHP
  • 26. Extending and Embedding PHP • Sara Golemon • Yahoo! Inc runkit • •4 5
  • 27. PHP5 • , () • •
  • 29. C • PHP • 5.2 »5.1 5.2.2 »5.2.1 •C
  • 30. PHP4 is DEAD!!! • PHP4 •PHP4 PHP5 »
  • 31. welcome PHP5 •PHP5 OOP » »interface •SPL •SimpleXML
  • 33.
  • 34. CodeGen_PECL Extension
  • 35. • CodeGen_PECL XML • pecl-gen • • •
  • 36. CodeGen_PECL ? • XML PECL • XML • PHP5 PEAR PHP4/5 4 »5
  • 37. ext_skel • PHP4 ext_skel • • • CodeGen_PECL IF
  • 38. • CodeGen_PECL » » http://www.m-takagi.org/ docs/php/CodeGen_PECL/ • PHP 2 gihyo.jp » » http://gihyo.jp/dev/serial/01/php- module/0002
  • 40. XML ( ) • ( ) • PECL » • » C or C++, platform(unix, win,all) » --with (header, lib path) Extension »
  • 41. XML ( ) • (function) ) code »proto( • »MINIT, RINIT »MSHUTDOWN, RSHUTDOWN »MINFO • OOP PHP4 OOP »CodeGen
  • 42. XML ( ) • (constant) • ini • • XML
  • 43. • • quot;study1quot; »
  • 44. PHP • : study1 • : study1_func() • ini : study1.ini • : STUDY1_CONSTANT
  • 45. • hello world • <?php function study1_greeting($name = quot;quot;) { if (strlen($name)) { echo quot;Hello, $name!quot;, PHP_EOL; } else { echo quot;Hello, World!quot;, PHP_EOL; } } ?>
  • 46.
  • 47. »PHP // void funcname(void); // int int int funcname(int param); Example 12.
  • 48. // 1 2 // string funcname(string param1 [[, string param2], string param3]); // int funcname([int param = 42]); // int funcname(string param1, ...); // object foo funcname(resource bar param1); Example 12.
  • 49. • • » » •
  • 50. 1 • • void study1_greeting([string name])
  • 52. • XML <extension> • name → quot;study1quot; » <?xml version=quot;1.0quot; ?> <!DOCTYPE extension SYSTEM quot;../extension.dtdquot;> <extension name=quot;study1quot;> </extension>
  • 53. (function ) • name → • <proto> <function name=quot;study1_greetingquot;> <proto>void study1_greeting([string name])</proto> <code> </code> <test> </test> </function>
  • 54. (code ) •C •
  • 55. • PHP • : string name • »const char *name int name_len » • »
  • 56. • http://www.m- takagi.org/docs/php/CodeGen_P ECL/x304.html#AEN377
  • 57. <code> if (name_len) { //php_printf(quot;Hello, %s%squot;, name, PHP_EOL); php_printf(quot;Hello, quot;); PHPWRITE(name, name_len); php_printf(quot;!%squot;, PHP_EOL); } else { php_printf(quot;Hello, World!%squot;, PHP_EOL); } </code>
  • 58. (function test ) • • test <test> <code> </code> <result mode=quot;plainquot;> </result> </test>
  • 59. (function test ) • <test> <code>study1_greeting();study1_gre eting(quot;Japanquot;);</code> <result mode=quot;plainquot;>Hello, World! Hello, Japan!</result> </test>
  • 60. <?xml version=quot;1.0quot; ?> <!DOCTYPE extension SYSTEM quot;../extension.dtdquot;> <extension name=quot;study1quot;> <function name=quot;study1_greetingquot;> <proto>void study1_greeting([string name])</proto> <code> if (name_len) { //php_printf(quot;Hello, %s%squot;, name, PHP_EOL); php_printf(quot;Hello, quot;); PHPWRITE(name, name_len); php_printf(quot;!%squot;, PHP_EOL); } else { php_printf(quot;Hello, World!%squot;, PHP_EOL); } </code> <test> <code>study1_greeting();study1_greeting(quot;Japanquot;);</code> <result mode=quot;plainquot;>Hello, World! Hello, Japan!</result> </test> </function> </extension>
  • 64. OK $ pecl-gen specfile.xml Warning: no 'version' attribute given for <extension>, assuming 1.1.0 this may lead to compile errors if your spec file was created for an older version Creating 'study1' extension in './study1' Your extension has been created in directory ./study1. See ./study1/README and/or ./study1/INSTALL for further instructions.
  • 65. study1 cd $ cd study1
  • 66. •phpize ( ) •./configure •make •make test •sudo make install
  • 67. phpize $ phpize Configuring for: PHP Api Version: 20041225 Zend Module Api No: 20060613 Zend Extension Api No: 220060519
  • 68. ./configure $ ./configure checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking for gcc... gcc checking for C compiler default output file name... a.out ... appending configuration tag quot;F77quot; to libtool configure: creating ./config.status config.status: creating config.h
  • 69. make $ make ... ---------------------------------------------------------------------- Libraries have been installed in: /home/iogiwara/work/extstudy/080122/2/study1/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'.
  • 70. make test • • make test php.ini extension
  • 71. make test $ make test ... ===================================================================== CWD : /home/iogiwara/work/extstudy/080122/2/study1 PHP : /usr/bin/php PHP_SAPI : cli PHP_VERSION : 5.2.3-1ubuntu6.3 ZEND_VERSION: 2.2.0 PHP_OS : Linux - Linux ubuntu-desktop 2.6.22-14-generic #1 ... INI actual : /etc/php5/cli/php.ini More .INIs : Extra dirs : ===================================================================== Running selected tests. PASS study1_greeting() function [tests/study1_greeting.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%) Tests passed : 1 (100.0%) (100.0%) --------------------------------------------------------------------- Time taken : 0 seconds =====================================================================
  • 72. sudo make install $ sudo make install Installing shared extensions: /usr/lib/php5/20060613+lfs/
  • 73. »-d extension=○ »-r $ php -dextension=study1.so –r 'study1_greeting();' Hello, World!
  • 74.
  • 76. •CodeGen_PECL ext_skel •
  • 77. »http://gihyo.jp/dev/serial/01/php -module/0002?page=2 • •C • config.m4