generate-ext - Create the subversion source layout for a new PHP extension that is PECL-ready

Introduction

The generate-pecl command is used to create a bare skeleton for a new PECL package or PHP extension as it will reside in Subversion. This is designed to provide all of the functionality of the ext_skel command but also generates a package.xml and other files that can be used to automatically update for a release.

One argument is accepted, extension.

This command automatically creates class definitions as well as ZEND_ARG_INFO for parameters to provide useful reflection to your extension's users.

extension

The extension argument is the name of the package to create a skeleton for. This is used as the directory name and as the extension name used within files related to creating a PECL package.

--proto

The --proto or -p option specifies a file containing function and method prototypes to create in your new extension.

As an example, here are some supported protos:

  • int myfunc(string firstarg, unicode secondarg, array thirdarg, object fourtharg [, double optionalarg1 [, float optionalarg2 [, callback optionalarg3 [, text optionalarg4]]]])
  • void Myclass::myfunc(array|object arg1, bool arg2, class arg3, resource arg4, mixed arg5 [, ... varargs])
  • static int Myclass::staticfunc()
  • protected string Myclass::otherguy([mixed optionalarg])
  • static protected object Myclass::factory(text path)

A proto begins with either the return type or access modifiers static and one of public, protected and private followed by the return type. Next, the name of the function, or name of the class::method is specified, followed by an argument list. Optional methods are enclosed in [brackets] and whitespace is important, so follow the conventions as in the above examples.

Each argument consists of a type followed by an argument name. The types are informed by parameter parsing as supported by PHP's internal zend_parse_parameters(). This is thoroughly documented in the file README.PARAMETER_PARSING inside PHP's source code. Note that some of the parameter parsing choices only work in PHP 6, in particular the unicode-related options.

The following types are supported:

  • array (maps to 'a' in parameter parsing)
  • array|object (maps to 'A' in parameter parsing)
  • bool (maps to 'b' in parameter parsing)
  • boolean (maps to 'b' in parameter parsing)
  • callback (maps to 'f' in parameter parsing)
  • class (Maps to 'C' in parameter parsing)
  • double (maps to 'd' in parameter parsing)
  • float (maps to 'd' in parameter parsing)
  • handle (maps to 'r' in parameter parsing)
  • int (Maps to 'L' in parameter parsing)
  • long (Maps to 'L' in parameter parsing)
  • mixed (maps to 'z' in parameter parsing)
  • object (maps to 'o' in parameter parsing)
  • resource (maps to 'r' in parameter parsing)
  • string (maps to 's' in parameter parsing)
  • text (Maps to 'T' in parameter parsing)
  • unicode (maps to 'u' in parameter parsing)
  • void, use only for the return value of a function that returns nothing
  • ... (varags: maps to '*' in parameter parsing) However, if the parameter is not optional, if maps to '+' is used.
generate-pear2 - Create the subversion source layout for a PEAR2 package (Previous) make - create a package.xml from its source directory (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.