09/12/2016 - PHP
If you follow the example below you can create an application independent composer package and use it in applications. This is a very basis example so you can enhance it based on your needs.
src
Helper
HelloHelper.php
.gitignore
.php_cs
build.xml
composer.json
composer.phar
Readme.md
{
"name": "inanzzz/hello-util",
"description": "I say hello!",
"type": "library",
"autoload": {
"psr-4": {
"Inanzzz\\HelloUtil\\": "src"
}
},
"require": {
},
"require-dev": {
"phing/phing": "2.11.0",
"friendsofphp/php-cs-fixer": "2.0.*@dev"
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "stable"
}
namespace Inanzzz\HelloUtil\Helper;
class HelloHelper
{
public function sayHello()
{
return 'Hello!';
}
}
bin
vendor
composer.lock
return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude(['bin', 'vendor'])
->in(__DIR__)
);
<?xml version = "1.0" encoding = "UTF-8"?>
<project name="hello-util" default="build">
<fileset id="src-files" dir=".">
<include name="**/*.php" />
<include name="*.php" />
<exclude name="vendor/**" />
</fileset>
<target name="build" depends="clean, composer, php-cs-fixer" />
<target name="clean" description="Cleaning in progress ...">
<delete file="composer.lock" quiet="true"/>
</target>
<target name="composer" description="Composer update ...">
<exec logoutput="true" checkreturn="true" passthru="true" command="composer self-update" dir="./" />
<exec logoutput="true" checkreturn="true" passthru="true" command="composer install" dir="./" />
</target>
<target name="php-cs-fixer" description="Checking coding standard ...">
<exec executable="php" passthru="true" checkreturn="true">
<arg value="bin/php-cs-fixer"/>
<arg value="fix"/>
<arg value="--dry-run"/>
<arg value="--verbose"/>
<arg value="--diff"/>
</exec>
</target>
</project>
# Install vendors
$composer install
# Run PSR coding standards tests
$ bin/phing php-cs-fixer