diff --git a/Module.php b/Module.php index cd218ed..ed72683 100644 --- a/Module.php +++ b/Module.php @@ -1,39 +1,7 @@ array( - 'PhingService' => function ($sm) { - $service = new \PhingService\Service(); - - $service->setOptions($sm->get('PhingService.serviceOptions')); - $service->setPhingOptions($sm->get('PhingService.phingOptions')); - - return $service; - }, - 'PhingService.serviceOptions' => function ($sm) { - $config = $sm->get('config'); - return new \PhingService\ServiceOptions($config['PhingService.serviceOptions']); - }, - 'PhingService.phingOptions' => function ($sm) { - $config = $sm->get('config'); - return new \PhingService\PhingOptions($config['PhingService.phingOptions']); - }, - ), - ); - } -} \ No newline at end of file +/** + * This file is placed here for compatibility with Zendframework 2's ModuleManager. + * It allows usage of this module even without composer. + * The original Module.php is in 'src/BsbPhingService' in order to respect PSR-0 + */ +require_once __DIR__ . '/src/BsbPhingService/Module.php'; diff --git a/README.md b/README.md index 500f8a0..7959694 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# PhingService +# BsbPhingService ## Introduction -PhingService is module for Zend Framework 2 that will enable you to run +BsbPhingService is module for Zend Framework 2 that will enable you to run [phing](http://www.phing.info/ "Phing") build files from within ZF2 projects. ## Requirements @@ -16,6 +16,7 @@ PLEASE USE AT YOUR OWN RISK. * v1.0.0-beta1 - initial release * v1.0.0-beta2 - 'composerized', updated to zf2-beta-4 + * v1.0.0-beta3 - updated to zf2 2.0.0+ / namespace and configuration key changed! [![Build Status](https://secure.travis-ci.org/basz/zf2-module-phing-service.png?branch=master)](http://travis-ci.org/basz/zf2-module-phing-service) @@ -32,7 +33,7 @@ in your project root. This will take care of dependancies. and then update cd /to/your/project/directory - php composer.phar update + ./composer.phar update -v ## Configuration @@ -41,7 +42,7 @@ and then update * Optionally copy `.../vendor/bushbaby/zf2-module-phing-service/config/module.phingservice.global.php.dist` to `.../config/autoload/module.phingservice.global.php` to override some defaults. -## How to use PhingService +## How to use BsbPhingService There is only one command to use which is `$Service->build($target, $phingOptions);`. The build method returns an associative array that contains the return status of the phing executable, the command has been issued and any output generated by phing (Both stdout and @@ -55,7 +56,7 @@ every controller so retrieval is trivial. public function indexAction() { $options = array('buildFile' => __DIR__ . '/../../../data/build-example.xml'); - $buildResult = $this->getServiceLocator()->get('PhingService')->build('show-defaults dist', $options); + $buildResult = $this->getServiceLocator()->get('BsbPhingService')->build('show-defaults dist', $options); if ($buildResult['returnStatus'] > 0) { // problem diff --git a/composer.json b/composer.json index 7cd599e..dc2570c 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ ], "require":{ "php": ">=5.3.3", - "phing/phing":"dev-master", - "zendframework/zendframework": "dev-master" + "phing/phing":">=2.4.12", + "zendframework/zendframework": "2.0.*" }, "autoload": { "psr-0": { diff --git a/configs/module.phingservice.global.php.dist b/configs/bsbphingservice.global.php.dist similarity index 85% rename from configs/module.phingservice.global.php.dist rename to configs/bsbphingservice.global.php.dist index aa3b231..0d76bc5 100644 --- a/configs/module.phingservice.global.php.dist +++ b/configs/bsbphingservice.global.php.dist @@ -30,19 +30,22 @@ $phingOptions = array( return array( - 'PhingService.serviceOptions' => $serviceOptions, - 'PhingService.phingOptions' => $phingOptions, + 'bsbphingservice' => array( + 'service' => $serviceOptions, + 'phing' => $phingOptions, + ), /* Enable the following section to get instant gratification at http://localhost/phingservice * 'router' => array( 'routes' => array( 'PhingService' => array( - 'type' => 'Zend\Mvc\Router\Http\Literal', + 'type' => 'Literal', 'options' => array( 'route' => '/phingservice', 'defaults' => array( - 'controller' => 'phingservice.index', + '__NAMESPACE__' => 'BsbPhingService\Controller', + 'controller' => 'Index', 'action' => 'index', ), ), diff --git a/configs/module.config.php b/configs/module.config.php index 47ba61d..94e8a2e 100644 --- a/configs/module.config.php +++ b/configs/module.config.php @@ -1,20 +1,25 @@ array( - 'phpBin' => null, /* will attempt auto-detection via exec 'which php' */ - 'phingPath' => null, /* will assume composer installation and attempt auto detect */ - ), - 'PhingService.phingOptions' => array( + 'bsbphingservice' => array( + 'service' => array( + 'phpBin' => null, /* will attempt auto-detection via exec 'which php' */ + 'phingPath' => null, /* will assume composer installation and attempt auto detect */ + ), + 'phing' => array( + + ), ), 'controllers' => array( 'invokables' => array( - 'phingservice.index' => 'PhingService\Controller\IndexController', + 'BsbPhingService\Controller\Index' => 'BsbPhingService\Controller\IndexController', ), ), 'view_manager' => array( - 'template_path_stack' => array( - 'PhingService' => __DIR__ . '/../view', + 'template_map' => array( + 'bsb-phing-service/index/index' => __DIR__ . '/../view/index/index.phtml', ), - ), -); + ) + ); + + diff --git a/src/PhingService/Controller/IndexController.php b/src/BsbPhingService/Controller/IndexController.php similarity index 64% rename from src/PhingService/Controller/IndexController.php rename to src/BsbPhingService/Controller/IndexController.php index c73ce58..326f416 100644 --- a/src/PhingService/Controller/IndexController.php +++ b/src/BsbPhingService/Controller/IndexController.php @@ -1,6 +1,6 @@ __DIR__ . '/../../../data/build-example.xml'); - $buildResult = $this->getServiceLocator()->get('PhingService')->build('show-defaults dist' /* target */, $options); + $buildResult = $this->getServiceLocator()->get('BsbPhingService')->build('show-defaults dist' /* target */, $options); $view = new ViewModel($buildResult); - $view->setTerminal(true); return $view; } diff --git a/src/BsbPhingService/Module.php b/src/BsbPhingService/Module.php new file mode 100644 index 0000000..b3f5e93 --- /dev/null +++ b/src/BsbPhingService/Module.php @@ -0,0 +1,70 @@ + array( + StandardAutoloader::LOAD_NS => array( + __NAMESPACE__ => __DIR__, + ), + ), + ); + } + + /** + * {@inheritDoc} + */ + public function getConfig($env = null) + { + return include __DIR__ . '/../../configs/module.config.php'; + } + + /** + * {@inheritDoc} + */ + public function getServiceConfig() + { + return array( + 'aliases' => array( + + ), + 'factories' => array( + 'BsbPhingService' => function ($sm) { + $service = new Service\Phing(); + + $service->setOptions($sm->get('BsbPhingService.serviceOptions')); + $service->setPhingOptions($sm->get('BsbPhingService.phingOptions')); + + return $service; + }, + 'BsbPhingService.serviceOptions' => function ($sm) { + $config = $sm->get('config'); + + return new ServiceOptions($config['bsbphingservice']['service']); + }, + 'BsbPhingService.phingOptions' => function ($sm) { + $config = $sm->get('config'); + + return new PhingOptions($config['bsbphingservice']['phing']); + }, + ), + ); + } +} \ No newline at end of file diff --git a/src/PhingService/PhingOptions.php b/src/BsbPhingService/Options/Phing.php similarity index 97% rename from src/PhingService/PhingOptions.php rename to src/BsbPhingService/Options/Phing.php index bb01190..38b9f69 100644 --- a/src/PhingService/PhingOptions.php +++ b/src/BsbPhingService/Options/Phing.php @@ -1,11 +1,11 @@ array( - __DIR__ . '/../autoload_classmap.php', - ), -)); -} diff --git a/tests/PhingServiceTest/ServiceTest.php b/tests/PhingServiceTest/ServiceTest.php index 903172c..f660c6c 100644 --- a/tests/PhingServiceTest/ServiceTest.php +++ b/tests/PhingServiceTest/ServiceTest.php @@ -1,10 +1,10 @@ service = new Service($so, $po); + $this->service = new Phing($so, $po); } public function testOptionDiscoveryPhpBin() diff --git a/view/phing-service/index/index.phtml b/view/index/index.phtml similarity index 100% rename from view/phing-service/index/index.phtml rename to view/index/index.phtml