/** * Generate README file (custom or default) * * @access private * @param string directory to write to */ function writeReadme() { $file = new CodeGen_Tools_Outbuf($this->dirpath . "/README"); $configOption = isset($this->with[$this->name]) ? "--with-" : "--enable-"; $configOption .= $this->name; ?> This is a standalone PHP extension created using CodeGen_PECL <?php echo self::version(); ?> HACKING ======= There are two ways to modify an extension created using CodeGen_PECL: 1) you can modify the generated code as with any other PHP extension 2) you can add custom code to the CodeGen_PECL XML source and re-run pecl-gen The 2nd approach may look a bit complicated but you have be aware that any manual changes to the generated code will be lost if you ever change the XML specs and re-run PECL-Gen. All changes done before have to be applied to the newly generated code again. Adding code snippets to the XML source itself on the other hand may be a bit more complicated but this way your custom code will always be in the generated code no matter how often you rerun CodeGen_PECL. <?php if ($this->platform->test("unix")) { ?> BUILDING ON UNIX etc. ===================== To compile your new extension, you will have to execute the following steps: 1. $ ./phpize 2. $ ./configure [<?php echo $configOption; ?> ] 3. $ make [4. $ make test ] # NOTE: this doesn't work right now *) 5. $ [sudo] make install *) this is a general problem with "make test" and standalone extensions (that is being worked on) so please don't blame CodeGen_PECL for this <?php } ?> <?php if ($this->platform->test("windows")) { ?> BUILDING ON WINDOWS =================== The extension provides the VisualStudio V6 project file <?php echo $this->name . ".dsp"; ?> To compile the extension you open this file using VisualStudio, select the apropriate configuration for your installation (either "Release_TS" or "Debug_TS") and create "php_<?php echo $this->name; ?> .dll" After successfull compilation you have to copy the newly created "php_<?php echo $this->name; ?> .dll" to the PHP extension directory (default: C:\PHP\extensions). <?php } ?> TESTING ======= You can now load the extension using a php.ini directive extension="php_<?php echo $this->name; ?> .[so|dll]" or load it at runtime using the dl() function dl("php_<?php echo $this->name; ?> .[so|dll]"); The extension should now be available, you can test this using the extension_loaded() function: if (extension_loaded(<?php echo $this->name; ?> )) echo "<?php echo $this->name; ?> loaded :)"; else echo "something is wrong :("; The extension will also add its own block to the output of phpinfo(); <?php $file->write(); }
/** * Write .cvsignore entries * * @access public * @param string directory to write to */ function writeDotCvsignore() { $file = new CodeGen_Tools_Outbuf($this->dirpath . "/.cvsignore"); // unix specific entries if ($this->platform->test("unix")) { echo "*.lo\n*.la\n.deps\n.libs\nMakefile\nMakefile.fragments\nMakefile.global\nMakefile.objects\nacinclude.m4\naclocal.m4\nautom4te.cache\nbuild\nconfig.cache\nconfig.guess\nconfig.h\nconfig.h.in\nconfig.log\nconfig.nice\nconfig.status\nconfig.sub\nconfigure\nconfigure.in\nconftest\nconftest.c\ninclude\ninstall-sh\nlibtool\nltmain.sh\nmissing\nmkinstalldirs\nmodules\nscan_makefile_in.awk\n"; } // windows specific entries if ($this->platform->test("windows")) { echo "*.dsw\n*.plg\n*.opt\n*.ncb\nRelease\nRelease_inline\nDebug\nRelease_TS\nRelease_TSDbg\nRelease_TS_inline\nDebug_TS\n"; } // "pear package" creates .tgz echo "{$this->name}*.tgz\n"; return $file->write(); }
/** * generate testcase file * * @access public * @param object the complete extension context */ function writeTest($extension) { $extName = $extension->getName(); $filename = "tests/{$this->name}.phpt"; $extension->addPackageFile("test", $filename); $file = new CodeGen_Tools_Outbuf($extension->dirpath . "/" . $filename); echo "--TEST--\n{$this->title}\n"; if (!empty($this->description)) { echo "--DESCRIPTION--\n{$this->description}\n"; } if (!empty($this->ini)) { echo "--INI--\n{$this->ini}\n"; } if (!empty($this->skipif)) { echo "--SKIPIF--\n<?php \n{$this->skipif}\n ?>\n"; } if (!empty($this->post)) { echo "--POST--\n{$this->post}\n"; } if (!empty($this->get)) { echo "--GET--\n{$this->get}\n"; } echo "--FILE--\n<?php\n{$this->code}\n?>\n"; switch ($this->mode) { case 'regex': echo "--EXPECTREGEX--\n"; break; case 'format': echo "--EXPECTF--\n"; break; case 'plain': default: echo "--EXPECT--\n"; break; } echo $this->output; $file->write(); }
/** * Generate README file (custom or default) * * @access private * @param string directory to write to */ function writeReadme() { $file = new CodeGen_Tools_Outbuf($this->dirpath . "/README"); $configOption = ""; if (count($this->with)) { foreach ($this->with as $with) { $configOption .= "[--with-" . $with->getName() . "=...] "; } } else { $configOption .= "[--enable--" . $this->name . "] "; } ?> This is a standalone PHP extension created using CodeGen_PECL <?php echo self::version(); ?> HACKING ======= There are two ways to modify an extension created using CodeGen_PECL: 1) you can modify the generated code as with any other PHP extension 2) you can add custom code to the CodeGen_PECL XML source and re-run pecl-gen The 2nd approach may look a bit complicated but you have be aware that any manual changes to the generated code will be lost if you ever change the XML specs and re-run PECL-Gen. All changes done before have to be applied to the newly generated code again. Adding code snippets to the XML source itself on the other hand may be a bit more complicated but this way your custom code will always be in the generated code no matter how often you rerun CodeGen_PECL. <?php if ($this->platform->test("unix")) { ?> BUILDING ON UNIX etc. ===================== To compile your new extension, you will have to execute the following steps: 1. $ ./phpize 2. $ ./configure <?php echo $configOption . "\n"; ?> 3. $ make 4. $ make test 5. $ [sudo] make install <?php } ?> TESTING ======= You can now load the extension using a php.ini directive extension="<?php echo $this->name; ?> .[so|dll]" or load it at runtime using the dl() function dl("<?php echo $this->name; ?> .[so|dll]"); The extension should now be available, you can test this using the extension_loaded() function: if (extension_loaded("<?php echo $this->name; ?> ")) echo "<?php echo $this->name; ?> loaded :)"; else echo "something is wrong :("; The extension will also add its own block to the output of phpinfo(); <?php $file->write(); }