Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartherbert committed Mar 21, 2011
0 parents commit 24142a0
Show file tree
Hide file tree
Showing 9 changed files with 576 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.build
dist
.tmp
nbproject
review
vendor
8 changes: 8 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax: glob

.build
.dist
nbproject
review
tmp
vendor
29 changes: 29 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
New BSD License
===============

Copyright (c) 2010, Gradwell dot com Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Gradwell dot com Ltd nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
84 changes: 84 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
ComponentManager
================

ComponentManager adds commands to phix to help you create and maintain a variety of PHP components.

To learn more about PHP components, Google for 'Beyond Frameworks'.

Installation
------------

You can install ComponentManager using the [PEAR Installer](http://pear.php.net). This installer is the community's de-facto standard for distributing PHP components.

sudo pear channel-discover pear.gradwell.com
sudo pear install --alldeps Gradwell/ComponentManager

After installation, you will find the code inside your local PEAR repository, which on Linux systems is normally /usr/share/php.

Documentation
-------------

Once installed, ComponentManager adds a number of commands to phix. You can get the list of available commands from phix:

# display phix's available commands
phix

# display the current version of ComponentManager
phix component-manager:version

Development Environment
-----------------------

If you want to patch or enhance this component, you will need to create a suitable development environment:

#phpunit
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover components.ez.no
sudo pear channel-discover pear.symfony-project.com
sudo pear install --alldeps phpunit/PHPUnit

# phing
sudo pear channel-discover pear.phing.info
sudo pear install --alldeps phing/phing

# pdepend
sudo pear channel-discover pear.pdepend.org
sudo pear install --alldeps pdepend/PHP_Depend-beta

# phpdoc
sudo pear install --alldeps pear/PhpDocumentor

# phpmd
sudo apt-get install php5-imagick
sudo pear channel-discover pear.phpmd.org
sudo pear install --alldeps phpmd/PHP_PMD-alpha

# phpcpd
sudo pear install --alldeps phpunit/phpcpd

# phpcs
sudo pear install --alldeps pear/PHP_CodeSniffer-beta

# phpcb
sudo pear install --alldeps phpunit/PHP_CodeBrowser

You can then clone the git repository:

# ComponentManager
git clone git://github.com/Gradwell/ComponentManager.git

You will then need to populate the vendor folder, to build a local copy of all of the dependencies for

# vendor folder
cd ComponentManager
phing build-vendor

To test your changes, you would do the following:

# test changes
phing test

# install changes into vendor folder, for local use
phing pear-package
phing install-local
vendor/bin/phix <command>
9 changes: 9 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
project.name=ComponentManager
project.majorVersion=1
project.minorVersion=0
project.patchLevel=0

checkstyle.standard=Zend

component.type=php-library
component.version=2
249 changes: 249 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- build file for phing -->
<project default="help" basedir=".">
<!-- Human-readable info about our component -->
<property file="build.properties" />

<property name="project.version" value="${project.majorVersion}.${project.minorVersion}.${project.patchLevel}" />
<property name="project.apiversion" value="${project.majorVersion}.${project.minorVersion}" />

<!-- Paths to the directories that we work with -->
<property name="project.srcdir" value="${project.basedir}/src" override="true" />
<property name="project.src.phpdir" value="${project.srcdir}/php" override="true" />
<property name="project.src.bindir" value="${project.srcdir}/bin" override="true" />
<property name="project.src.datadir" value="${project.srcdir}/data" override="true" />
<property name="project.src.testdir" value="${project.srcdir}/tests" override="true" />
<property name="project.src.wwwdir" value="${project.srcdir}/www" override="true" />
<property name="project.src.testunitdir" value="${project.src.testdir}/unit-tests" override="true" />
<property name="project.src.testintdir" value="${project.src.testdir}/integration-tests" override="true" />
<property name="project.src.testfuncdir" value="${project.src.testdir}/functional-tests" override="true" />

<property name="project.reviewdir" value="${project.basedir}/review" override="true" />
<property name="project.review.logsdir" value="${project.basedir}/review/logs" override="true" />
<property name="project.review.docsdir" value="${project.reviewdir}/docs" override="true" />
<property name="project.review.codebrowserdir" value="${project.reviewdir}/code-browser" override="true" />
<property name="project.review.codecoveragedir" value="${project.reviewdir}/code-coverage" override="true" />

<property name="project.builddir" value="${project.basedir}/.build" override="true" />
<property name="project.pkgdir" value="${project.builddir}/${project.name}-${project.version}" override="true" />
<property name="project.tmpdir" value="${project.basedir}/.tmp" override="true" />

<property name="project.vendordir" value="${project.basedir}/vendor" override="true" />
<property name="project.vendor.bindir" value="${project.vendordir}/bin" override="true" />
<property name="project.vendor.datadir" value="${project.vendordir}/data" override="true" />
<property name="project.vendor.phpdir" value="${project.vendordir}/php" override="true" />
<property name="project.vendor.testdir" value="${project.vendordir}/tests" override="true" />
<property name="project.vendor.docdir" value="${project.vendordir}/docs" override="true" />
<property name="project.vendor.wwwdir" value="${project.vendordir}/www" override="true" />

<property name="project.distdir" value="${project.basedir}/dist" />
<property name="project.tarfilename" value="${project.name}-${project.version}.tgz" />
<property name="project.tarfile" value="${project.distdir}/${project.tarfilename}" />

<!-- a user to use to publish on the pear server -->
<property name="remote.user" value="" override="true" />

<!-- lists of the files that make up our package -->
<fileset dir="${project.src.bindir}" id="binfiles">
<include name="**/**"/>
</fileset>
<fileset dir="${project.src.datadir}" id="datafiles">
<include name="**/**"/>
</fileset>
<fileset dir="${project.src.phpdir}" id="phpfiles">
<include name="**/**"/>
</fileset>
<fileset dir="${project.src.testunitdir}/php" id="testfiles">
<include name="**/**"/>
</fileset>
<fileset dir="${project.src.wwwdir}" id="wwwfiles">
<include name="**/**" />
</fileset>

<!-- Tell the user what this build file supports -->
<target name="help">
<echo message="${project.name} ${project.version}: build.xml targets:" />
<echo message="" />
<echo message="lint" />
<echo message=" Check the PHP files for syntax errors" />
<echo message="test" />
<echo message=" Run the component's PHPUnit tests" />
<echo message="code-review" />
<echo message=" Run all of the code quality targets:" />
<echo message="" />
<echo message=" code-browser" />
<echo message=" Run code quality tests for PHP_CodeBrowser" />
<echo message=" phpcpd" />
<echo message=" Check for cut and paste problems" />
<echo message=" phpdoc" />
<echo message=" Create the PHP docs from source code" />
<echo message="" />
<echo message="build-vendor" />
<echo message=" Populate vendor/ with this package's dependencies" />
<echo message="pear-package" />
<echo message=" Create a PEAR-compatible package" />
<echo message="install-vendor" />
<echo message=" Install this component from source into vendor/" />
<echo message="install-system" />
<echo message=" Install this component from source for all local users" />
<echo message=" You must be root to run this target on Linux!!" />
<echo message="clean" />
<echo message=" Remove all temporary folders created by this build file" />
</target>

<!-- Run PHP lint on all of the source code -->
<target name="lint">
<phplint>
<fileset dir="${project.src.phpdir}">
<include name="**/*.php" />
</fileset>
</phplint>
</target>

<!-- Run the unit tests for this module -->
<target name="run-unittests" depends="lint">
<delete dir="${project.review.codecoveragedir}" />
<mkdir dir="${project.review.codecoveragedir}" />
<mkdir dir="${project.review.logsdir}" />
<exec command="phpunit --bootstrap=${project.src.testunitdir}/bootstrap.php --coverage-html ${project.review.codecoveragedir} --coverage-clover ${project.review.logsdir}/phpunit.xml ${project.src.testunitdir}" checkreturn="true" logoutput="true"/>
<echo/>
<echo>The code coverage report is in ${project.review.codecoveragedir}</echo>
</target>

<!-- Run all the tests for this module -->
<target name="test" depends="run-unittests" />

<!-- Run the code review quality tests -->
<target name="code-review" depends="run-unittests, code-browser, phpcpd, pdepend" />

<!-- Run all of the targets for setting up the code browser -->
<target name="code-browser" depends="phpmd, phpcs, phpcb" />

<target name="pdepend">
<mkdir dir="${project.review.logsdir}" />
<exec command="pdepend --phpunit-xml=${project.review.logsdir}/pdepend.xml --jdepend-xml=${project.review.logsdir}/jdepend.xml --jdepend-chart=${project.review.logsdir}/dependencies.svg --overview-pyramid=${project.review.logsdir}/overview-pyramid.svg ${project.src.phpdir}" logoutput="true"/>
</target>

<!-- Generate package docs -->
<target name="phpdoc">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpdoc -d ${project.src.phpdir} -t ${project.review.docsdir}" logoutput="true"/>
<echo message="You will find the PHPDoc for your project at: ${project.review.docsdir}/index.html"/>
</target>

<!-- Check code for code smells -->
<target name="phpmd">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpmd ${project.src.phpdir} xml codesize,design,naming,unusedcode --reportfile ${project.review.logsdir}/phpmd.xml" logoutput="true" />
</target>

<target name="phpcpd">
<mkdir dir="${project.review.logsdir}"/>
<exec command="phpcpd --log-pmd ${project.review.logsdir}/pmd-cpd.xml ${project.src.phpdir}" logoutput="true" />
</target>

<!-- Check the code for style violations -->
<target name="phpcs">
<mkdir dir="${project.review.logsdir}" />
<exec command="phpcs --report=xml --report-file=${project.review.logsdir}/checkstyle.xml --standard=${checkstyle.standard} --extensions=php ${project.src.phpdir}" logoutput="true"/>
</target>

<!-- Build the code-browser files -->
<target name="phpcb" depends="phpmd">
<delete dir="${project.review.codebrowserdir}" />
<mkdir dir="${project.review.codebrowserdir}" />
<exec command="phpcb --log ${project.review.logsdir} --source ${project.src.phpdir} --output ${project.review.codebrowserdir}" logoutput="true" />
</target>

<!-- Populate vendor with the dependencies for this component -->
<target name="build-vendor" depends="pear-package,setup-vendor">
<echo>Populating vendor/ with dependencies</echo>
<exec command="phix pear:register-channels" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config install --alldeps ${project.builddir}/package.xml" logoutput="true" checkreturn="true"/>
</target>

<!-- Setup the vendor folder -->
<target name="setup-vendor">
<echo>Creating vendor/ as a sandboxed PEAR install folder</echo>
<delete dir="${project.vendordir}" />
<mkdir dir="${project.vendordir}" />
<delete dir="${project.tmpdir}" />
<mkdir dir="${project.tmpdir}" />
<exec command="pear config-create ${project.tmpdir} ${project.tmpdir}/pear-config" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set preferred_state alpha" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set php_dir ${project.vendor.phpdir}" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set bin_dir ${project.vendor.bindir}" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set data_dir ${project.vendor.datadir}" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set doc_dir ${project.vendor.docdir}" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set test_dir ${project.vendor.testdir}" checkreturn="true" logoutput="true" />
<exec command="pear -c ${project.tmpdir}/pear-config config-set www_dir ${project.vendor.wwwdir}" checkreturn="true" logoutput="true" />
</target>

<!-- Create a dummy PEAR package to satisfy lib-vendor -->
<target name="pear-package-for-lib-vendor">
<echo>Building release directory</echo>
<delete dir="${project.builddir}" />
<mkdir dir="${project.pkgdir}" />
<copy todir="${project.pkgdir}">
<fileset refid="phpfiles"/>
</copy>
<copy todir="${project.builddir}">
<fileset dir=".">
<include name="package.xml" />
</fileset>
</copy>
<copy file="${project.basedir}/build.xml" tofile="${project.builddir}/build.xml" overwrite="true" />
<exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>
</target>

<!-- Create the PEAR package, ready for release -->
<target name="pear-package">
<echo>Building release directory</echo>
<delete dir="${project.builddir}" />
<mkdir dir="${project.pkgdir}" />
<copy todir="${project.pkgdir}">
<fileset refid="binfiles"/>
<fileset refid="datafiles"/>
<fileset refid="phpfiles"/>
<fileset refid="testfiles"/>
<fileset refid="wwwfiles"/>
</copy>
<copy todir="${project.builddir}">
<fileset dir=".">
<include name="package.xml" />
</fileset>
</copy>

<exec command="phix pear:expand-package-xml" checkreturn="yes" logoutput="yes"/>

<echo>Creating ${project.tarfile} PEAR package</echo>

<mkdir dir="${project.distdir}" />
<delete file="${project.tarfile}" />
<tar destfile="${project.tarfile}" compression="gzip">
<fileset dir="${project.builddir}">
<include name="*" />
</fileset>
</tar>
<echo>Your PEAR package is in ${project.tarfile}</echo>
</target>

<!-- Install the code -->
<target name="install-vendor">
<exec command="pear -c ${project.tmpdir}/pear-config install --alldeps -f ${project.tarfile}" logoutput="true" checkreturn="true"/>
</target>
<target name="install-system">
<exec command="pear install -f -a ${project.tarfile}" checkreturn="true" logoutput="true" />
</target>

<!-- Clean up the mess -->
<target name="clean">
<delete dir="${project.builddir}" />
<delete dir="${project.distdir}" />
<delete dir="${project.reviewdir}" />
<delete dir="${project.pkgdir}" />
<delete dir="${project.distdir}" />
<delete dir="${project.tmpdir}" />
</target>
</project>
<!-- vim: set tabstop=2 shiftwidth=2 expandtab: -->
Loading

0 comments on commit 24142a0

Please sign in to comment.