Go to file
MarkMaldaba 251f4d6713 Fix for running PHP under CGI on Windows machines. In this situation, the environement variables defining the system temp path are not necessarily available to PHP, so sys_get_temp_dir() falls back to using the system path (e.g. C:\WINDOWS), which is normally unwritable. This means that temp-file creation fails.
I've added code to detect this situation, and if it occurs we point it to %SystemRoot%\TEMP instead, which usually is present and writable.  May not fix 100% of cases, but should fix the vast majority of situations where this may occur.
2013-05-15 16:04:55 +01:00
assets Removing un-minified bootstrap JS, and a star ratings library carried over when starting the project. 2013-05-14 13:11:30 +01:00
PHPCI Fix for running PHP under CGI on Windows machines. In this situation, the environement variables defining the system temp path are not necessarily available to PHP, so sys_get_temp_dir() falls back to using the system path (e.g. C:\WINDOWS), which is normally unwritable. This means that temp-file creation fails. 2013-05-15 16:04:55 +01:00
.gitignore Adding a basic installer. 2013-05-10 15:00:42 +01:00
bootstrap.php Initial commit. 2013-05-03 16:02:53 +01:00
composer.json I've replaced the requirement for the pecl yaml extension with the symphony component. Sometimes I work on a windows box and the instructions for installing pecl yaml on windows looked a little intimidating: 2013-05-14 18:15:57 +01:00
cron.php Updating PHPCI to use Composer-installed copies of the plugin requirements 2013-05-10 15:00:24 +01:00
generate.php Initial commit. 2013-05-03 16:02:53 +01:00
index.php Adding user accounts. 2013-05-10 16:25:51 +01:00
install.php Github pull request status updates 2013-05-14 16:58:14 +01:00
LICENSE.md Adding LICENSE file. 2013-05-10 16:53:56 +01:00
phpci.yml Fixing phpci.yml, use spaces not tabs 2013-05-14 20:00:52 +01:00
README.md Modified the PHPunit plugin so that it can take multiple config files and dirs and will combine the results of each. 2013-05-15 13:41:30 +01:00

PHPCI

PHPCI is a free and open source continuous integration tool specifically designed for PHP. We've built it with simplicity in mind, so whilst it doesn't do everything Jenkins can do, it is a breeze to set up and use.

Please be aware that this is a brand new project, in an alpha state, so there will be bugs and missing features.

##What it does:

  • Clones your project from Github, Bitbucket or a local path (support for standard remote Git repositories coming soon.)
  • Allows you to set up and tear down test databases.
  • Installs your project's Composer dependencies.
  • Runs through any combination of the following plugins:
    • PHP Unit
    • PHP Mess Detector
    • PHP Copy/Paste Detector
    • PHP Code Sniffer
    • PHP Spec
  • You can mark directories for the plugins to ignore.
  • You can mark certain plugins as being allowed to fail (but still run.)

##What it doesn't do (yet):

  • Virtualised testing.
  • Multiple PHP-version tests.
  • Multiple testing workers.
  • Install PEAR or PECL extensions.
  • Deployments.
  • Success / Failure emails.

##Installing PHPCI: ####Pre-requisites:

  • PHP 5.3+
  • A web server. We prefer nginx.
  • The YAML extension: pecl install yaml
  • A MySQL server to connect to (doesn't have to be on the same server.)
  • PHPCI needs to be able to run exec(), so make sure this is not disabled.

####Installing from Github:

  • Step 1: git clone https://github.com/Block8/PHPCI.git
  • Step 2: cd PHPCI
  • Step 3: php install.php
    • When prompted, enter your database host, username, password and the database name that PHPCI should use.
    • The script will attempt to create the database if it does not exist already.
    • If you intend to use the MySQL plugin to create / destroy databases, the user you entered above will need CREATE / DELETE permissions on the server.
  • Add a virtual host to your web server, pointing to the directory you cloned PHPCI into.
  • You'll need to set up rewrite rules to point all non-existant requests to PHPCI.

Apache Example:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

Nginx Example:

location / {
    try-files $uri $uri/ index.php
}

Finally, you'll want to set up PHPCI to run as a regular cronjob, so run crontab -e and enter the following:

* * * * * /usr/bin/php /path/to/phpci/cron.php

Obviously, make sure you change the /path/to/phpci to the directory in which you installed PHPCI, and update the PHP path if necessary.

##Adding support for PHPCI to your projects: Similar to Travis CI, to support PHPCI in your project, you simply need to add a phpci.yml file to the root of your repository. The file should look something like this:

build_settings:
    ignore:
        - "vendor"
        - "tests"

setup:
	mysql:
		- "DROP DATABASE IF EXISTS test;"
		- "CREATE DATABASE test;"
		- "GRANT ALL PRIVILEGES ON test.* TO test@'localhost' IDENTIFIED BY 'test';"
	composer:
		action: "install"

test:
	php_unit:
		config:
			- "PHPUnit-all.xml"
			- "PHPUnit-ubuntu-fix.xml"
		directory:
			- "tests/"
	php_mess_detector:
		allow_failures: true
	php_code_sniffer:
		standard: "PSR2"
	php_cpd:
		allow_failures: true

complete:
	mysql:
		- "DROP DATABASE IF EXISTS test;"

As mentioned earlier, PHPCI is powered by plugins, there are several phases in which plugins can be run:

  • setup - This phase is designed to initialise the build procedure.
  • test - The tests that should be run during the build. Plugins run during this phase will contribute to the success or failure of the build.
  • complete - Always called when the test phase completes, regardless of success or failure.
  • success - Called upon success of the test phase.
  • failure - Called upon the failure of the test phase.

The ignore section is merely an array of paths that should be ignored in all tests (where possible.)

##Contributing Contributions from others would be very much appreciated! Simply fork the repository, and send us a pull request when you're ready.

##Questions? Email us at hello+phpci@block8.co.uk and we'll do our best to help!