PHPackages                             jimthunderbird/php-to-c-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. jimthunderbird/php-to-c-extension

ActiveLibrary[CLI &amp; Console](/categories/cli)

jimthunderbird/php-to-c-extension
=================================

A command line tool to build Zend Based PHP extensions using PHP and C

1281226[8 issues](https://github.com/jimthunderbird/php-to-c-extension/issues)PHP

Since Jan 21Pushed 9y ago13 watchersCompare

[ Source](https://github.com/jimthunderbird/php-to-c-extension)[ Packagist](https://packagist.org/packages/jimthunderbird/php-to-c-extension)[ RSS](/packages/jimthunderbird-php-to-c-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

PHP-TO-C-Ext is a tool to allow developer to build Zend Engine based PHP Extensions using PHP together with C.

PHP-TO-C-EXT is built on top of these great things:

- Zephir ()
- PHP Parser ()
- PHP to Zephir ()

PHP-TO-C-EXT is tested on Fedora Linux 21 and Mac OS Yosemite From PHP 5.4 to 5.6.

\##Installation

1. Install composer
2. git clone
3. cd php-to-c-extension
4. composer.phar install

\##Usage:

```
$ php [path/to/php-to-c-extension]/build_extensions.php [php file to convert to c extension]
```

or

```
$ php [path/to/php-to-c-extension]/build_extensions.php [directory containing php files to convert to c extension]
```

\##Examples:

- [A simple dummy extension](#example-01)
- [One namespace and multiple classes in one file](#example-02)
- [Organize multiple files in one directory](#example-03)
- [Using for loop](#example-04)
- \[Using sub-namespaces\] (#example-05)
- \[Using interface\] (#example-06)
- \[Using trait\] (#example-07)
- [Calling method in the base class with parent::](#example-08)
- [Using the self keyword](#example-09)
- [Using ternary operator](#example-10)
- [Late static binding](#example-11)
- [Performance Benchmark: Bubble Sort](#example-12)
- [Gain greater speed through raw C code, using call\_c\_function](#example-13)
- [Using PHP Code together with raw C code to solve problems, using call\_c\_function](#example-14)
- [Better code structure and saving development time when working with raw C code, using call\_c\_auto](#example-15)

\###Example 01

Let's create a file named Dummy.php, it looks like this:

```
