| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Tool
- * @subpackage Framework
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Tool_Project_Provider_Abstract
- */
- require_once 'Zend/Tool/Project/Provider/Abstract.php';
- /**
- * @category Zend
- * @package Zend_Tool
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Tool_Project_Provider_Project
- extends Zend_Tool_Project_Provider_Abstract
- //implements Zend_Tool_Framework_Provider_DocblockManifestInterface
- {
- protected $_specialties = array('Info');
- /**
- * create()
- *
- * @param string $path
- * @param string $nameOfProfile shortName=n
- * @param string $fileOfProfile shortName=f
- */
- public function create($path, $nameOfProfile = null, $fileOfProfile = null)
- {
- if ($path == null) {
- $path = getcwd();
- } else {
- $path = trim($path);
- if (!file_exists($path)) {
- $created = mkdir($path);
- if (!$created) {
- require_once 'Zend/Tool/Framework/Client/Exception.php';
- throw new Zend_Tool_Framework_Client_Exception('Could not create requested project directory \'' . $path . '\'');
- }
- }
- $path = str_replace('\\', '/', realpath($path));
- }
- $profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE, $path);
- if ($profile !== false) {
- require_once 'Zend/Tool/Framework/Client/Exception.php';
- throw new Zend_Tool_Framework_Client_Exception('A project already exists here');
- }
- $profileData = null;
- if ($fileOfProfile != null && file_exists($fileOfProfile)) {
- $profileData = file_get_contents($fileOfProfile);
- }
- $storage = $this->_registry->getStorage();
- if ($profileData == '' && $nameOfProfile != null && $storage->isEnabled()) {
- $profileData = $storage->get('project/profiles/' . $nameOfProfile . '.xml');
- }
- if ($profileData == '') {
- $profileData = $this->_getDefaultProfile();
- }
- $newProfile = new Zend_Tool_Project_Profile(array(
- 'projectDirectory' => $path,
- 'profileData' => $profileData
- ));
- $newProfile->loadFromData();
- $response = $this->_registry->getResponse();
- $response->appendContent('Creating project at ' . $path);
- $response->appendContent('Note: ', array('separator' => false, 'color' => 'yellow'));
- $response->appendContent(
- 'This command created a web project, '
- . 'for more information setting up your VHOST, please see docs/README');
- if (!Zend_Tool_Project_Provider_Test::isPHPUnitAvailable()) {
- $response->appendContent('Testing Note: ', array('separator' => false, 'color' => 'yellow'));
- $response->appendContent('PHPUnit was not found in your include_path, therefore no testing actions will be created.');
- }
-
- foreach ($newProfile->getIterator() as $resource) {
- $resource->create();
- }
- }
- public function show()
- {
- $this->_registry->getResponse()->appendContent('You probably meant to run "show project.info".', array('color' => 'yellow'));
- }
- public function showInfo()
- {
- $profile = $this->_loadProfile(self::NO_PROFILE_RETURN_FALSE);
- if (!$profile) {
- $this->_registry->getResponse()->appendContent('No project found.');
- } else {
- $this->_registry->getResponse()->appendContent('Working with project located at: ' . $profile->getAttribute('projectDirectory'));
- }
- }
- protected function _getDefaultProfile()
- {
- $testAction = '';
- if (Zend_Tool_Project_Provider_Test::isPHPUnitAvailable()) {
- $testAction = ' <testApplicationActionMethod forActionName="index" />';
- }
-
- $version = Zend_Version::VERSION;
- $data = <<<EOS
- <?xml version="1.0" encoding="UTF-8"?>
- <projectProfile type="default" version="$version">
- <projectDirectory>
- <projectProfileFile />
- <applicationDirectory>
- <configsDirectory>
- <applicationConfigFile type="ini" />
- </configsDirectory>
- <controllersDirectory>
- <controllerFile controllerName="Index">
- <actionMethod actionName="index" />
- </controllerFile>
- <controllerFile controllerName="Error" />
- </controllersDirectory>
- <formsDirectory enabled="false" />
- <layoutsDirectory enabled="false" />
- <modelsDirectory />
- <modulesDirectory enabled="false" />
- <servicesDirectory enabled="false" />
- <viewsDirectory>
- <viewScriptsDirectory>
- <viewControllerScriptsDirectory forControllerName="Index">
- <viewScriptFile forActionName="index" />
- </viewControllerScriptsDirectory>
- <viewControllerScriptsDirectory forControllerName="Error">
- <viewScriptFile forActionName="error" />
- </viewControllerScriptsDirectory>
- </viewScriptsDirectory>
- <viewHelpersDirectory />
- <viewFiltersDirectory enabled="false" />
- </viewsDirectory>
- <bootstrapFile />
- </applicationDirectory>
- <dataDirectory enabled="false">
- <cacheDirectory enabled="false" />
- <searchIndexesDirectory enabled="false" />
- <localesDirectory enabled="false" />
- <logsDirectory enabled="false" />
- <sessionsDirectory enabled="false" />
- <uploadsDirectory enabled="false" />
- </dataDirectory>
- <docsDirectory>
- <file filesystemName="README.txt" defaultContentCallback="Zend_Tool_Project_Provider_Project::getDefaultReadmeContents"/>
- </docsDirectory>
- <libraryDirectory>
- <zfStandardLibraryDirectory enabled="false" />
- </libraryDirectory>
- <publicDirectory>
- <publicStylesheetsDirectory enabled="false" />
- <publicScriptsDirectory enabled="false" />
- <publicImagesDirectory enabled="false" />
- <publicIndexFile />
- <htaccessFile />
- </publicDirectory>
- <projectProvidersDirectory enabled="false" />
- <temporaryDirectory enabled="false" />
- <testsDirectory>
- <testPHPUnitConfigFile />
- <testPHPUnitBootstrapFile />
- <testApplicationDirectory>
- <testApplicationControllerDirectory>
- <testApplicationControllerFile filesystemName="IndexControllerTest.php" forControllerName="Index">
- $testAction
- </testApplicationControllerFile>
- </testApplicationControllerDirectory>
- </testApplicationDirectory>
- <testLibraryDirectory />
- </testsDirectory>
- </projectDirectory>
- </projectProfile>
- EOS;
- return $data;
- }
- public static function getDefaultReadmeContents($caller = null)
- {
- $projectDirResource = $caller->getResource()->getProfile()->search('projectDirectory');
- if ($projectDirResource) {
- $name = ltrim(strrchr($projectDirResource->getPath(), DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
- $path = $projectDirResource->getPath() . '/public';
- } else {
- $path = '/path/to/public';
- }
- return <<< EOS
- README
- ======
- This directory should be used to place project specfic documentation including
- but not limited to project notes, generated API/phpdoc documentation, or
- manual files generated or hand written. Ideally, this directory would remain
- in your development environment only and should not be deployed with your
- application to it's final production location.
- Setting Up Your VHOST
- =====================
- The following is a sample VHOST you might want to consider for your project.
- <VirtualHost *:80>
- DocumentRoot "$path"
- ServerName $name.local
- # This should be omitted in the production environment
- SetEnv APPLICATION_ENV development
- <Directory "$path">
- Options Indexes MultiViews FollowSymLinks
- AllowOverride All
- Order allow,deny
- Allow from all
- </Directory>
- </VirtualHost>
- EOS;
- }
- }
|