First, prepare Maven and follow the preparation instructions.
Next, type the following Maven goal in your command line and execute it
(Note that PHP 4 is not supported since phpmaven2.):
mvn archetype:generate \ -DarchetypeGroupId=org.phpmaven \ -DarchetypeArtifactId=php5-web-archetype \ -DarchetypeVersion=2.0-SNAPSHOT \ -DgroupId=org.sample \ -DartifactId=my-app \
my-app |-- pom.xml `-- src |-- main `-- php `-- org `-- sample `-- app.php `-- webapp `-- index.php |`-- test `-- php `-- org `-- sample `-- apptest.php `-- webapp `-- index.php |`-- site `-- doxygen `-- doxygen.conf
For PHP 4 (1.*) and PHP 5 (3.*) different PHPUnit versions are used. Accordingly, there are different dependencies in the POM.
<?xml version="1.0" encoding="UTF-8"?> <project> <modelVersion>4.0.0</modelVersion> <groupId>org.phpsample</groupId> <artifactId>my-app</artifactId> <packaging>php</packaging> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.phpmaven</groupId> <artifactId>maven-php-plugin</artifactId> <extensions>true</extensions> </plugin> <!-- The web assembyl --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-2</version> <dependencies> <dependency> <groupId>org.phpmaven</groupId> <artifactId>maven-php-plugin</artifactId> <version>1.0</version> </dependency> </dependencies> <executions> <execution> <id>bundle-project-sources</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptorRefs> <descriptorRef>php-webapp</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-site-plugin</artifactId> <version>3.0</version> <configuration> <reportPlugins> <plugin> <groupId>org.phpmaven</groupId> <artifactId>maven-php-plugin</artifactId> <reportSets> <reportSet> <reports> <report>phpdocumentor</report> </reports> </reportSet> </reportSets> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> <version>2.10</version> <reportSets> <reportSet> <reports> <report>report-only</report> </reports> </reportSet> </reportSets> </plugin> </reportPlugins> </configuration> </plugin> </plugins> </build> <dependencies> <!-- phpUnit for PHP 5 --> <dependency> <groupId>org.phpunit</groupId> <artifactId>phpunit5</artifactId> <version>3.2.9-SNAPSHOT</version> </dependency> <!-- phpUnit for PHP 4 --> <dependency> <groupId>org.phpunit</groupId> <artifactId>phpunit4</artifactId> <version>1.3.2-SNAPSHOT</version> </dependency> </dependencies> </project>
What have I just done?
You have just executed the Maven goal archetype:generate and passed various parameters to that goal. The prefix archetype is the plugin containing the goal. This goal created a default project structure for your PHP 4 project.cd my-app
mvn package
... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6 seconds [INFO] Finished at: Thu Jul 20 19:15:06 CDT 2008 [INFO] Final Memory: 3M/6M [INFO] ------------------------------------------------------------------------
"Maven for PHP" validates the PHP code with the php.exe, runs PHPUnit tests, and creates an assembly for the web project.
Go to the "Documentation" section.
Go to the "Deploy" section.
Go to the "Documentation" section.