Re: ShellDispatcher help

2013-11-01 Thread AD7six
I'd guess you're using php 4 
https://github.com/cakephp/cakephp/blob/master/lib/Cake/Console/ShellDispatcher.php#L32

On Friday, 1 November 2013 02:37:55 UTC+1, Jared Testa wrote:
>
> I'm new to CakePHP.  My first install was 2.4.1, right before .2 came out. 
>  I tried using Shell in .1 and got an error.  I also noticed the update the 
> same time, so I went ahead and updated to .2.
>
> I'm getting a syntax error when trying to run Console/cake.  
>
> Parse error:  syntax error, unexpected T_STRING, expecting 
> T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in 
> /home/content/15/10888415/html/flight/lib/Cake/Console/ShellDispatcher.php
>  
> on line 33
>
> Yes, a simple syntax error.  I HAVE NOT modified anything in the LIB 
> directory.  Here is my entire ShellDispatcher.php file:
>
>  /**
>  * ShellDispatcher file
>  *
>  * PHP 5
>  *
>  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
>  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org
> )
>  *
>  * Licensed under The MIT License
>  * For full copyright and license information, please see the LICENSE.txt
>  * Redistributions of files must retain the above copyright notice.
>  *
>  * @copyright Copyright (c) Cake Software Foundation, Inc. (
> http://cakefoundation.org)
>  * @link  http://cakephp.org CakePHP(tm) Project
>  * @since CakePHP(tm) v 2.0
>  * @license   http://www.opensource.org/licenses/mit-license.php MIT 
> License
>  */
>
> /**
>  * Shell dispatcher handles dispatching cli commands.
>  *
>  * @package   Cake.Console
>  */
> class ShellDispatcher {
>
> /**
>  * Contains command switches parsed from the command line.
>  *
>  * @var array
>  */
> public $params = array();
>
> /**
>  * Contains arguments parsed from the command line.
>  *
>  * @var array
>  */
> public $args = array();
>
> /**
>  * Constructor
>  *
>  * The execution of the script is stopped after dispatching the request 
> with
>  * a status code of either 0 or 1 according to the result of the dispatch.
>  *
>  * @param array $args the argv from PHP
>  * @param boolean $bootstrap Should the environment be bootstrapped.
>  */
> public function __construct($args = array(), $bootstrap = true) {
> set_time_limit(0);
> $this->parseParams($args);
>
> if ($bootstrap) {
> $this->_initConstants();
> $this->_initEnvironment();
> }
> }
>
> /**
>  * Run the dispatcher
>  *
>  * @param array $argv The argv from PHP
>  * @return void
>  */
> public static function run($argv) {
> $dispatcher = new ShellDispatcher($argv);
> return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
> }
>
> /**
>  * Defines core configuration.
>  *
>  * @return void
>  */
> protected function _initConstants() {
> if (function_exists('ini_set')) {
> ini_set('html_errors', false);
> ini_set('implicit_flush', true);
> ini_set('max_execution_time', 0);
> }
>
> if (!defined('CAKE_CORE_INCLUDE_PATH')) {
> define('DS', DIRECTORY_SEPARATOR);
> define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__;
> define('CAKEPHP_SHELL', true);
> if (!defined('CORE_PATH')) {
> define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
> }
> }
> }
>
> /**
>  * Defines current working environment.
>  *
>  * @return void
>  * @throws CakeException
>  */
> protected function _initEnvironment() {
> if (!$this->_bootstrap()) {
> $message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 
> 'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
> throw new CakeException($message);
> }
>
> if (!isset($this->args[0]) || !isset($this->params['working'])) {
> $message = "This file has been loaded incorrectly and cannot continue.\n" .
> "Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in 
> your system path,\n" .
> "and check the cookbook for the correct usage of this command.\n" .
> "(http://book.cakephp.org/)";
> throw new CakeException($message);
> }
>
> $this->shiftArgs();
> }
>
> /**
>  * Initializes the environment and loads the CakePHP core.
>  *
>  * @return boolean Success.
>  */
> protected function _bootstrap() {
> if (!defined('ROOT')) {
> define('ROOT', $this->params['root']);
> }
> if (!defined('APP_DIR')) {
> define('APP_DIR', $this->params['app']);
> }
> if (!defined('APP')) {
> define('APP', $this->params['working'] . DS);
> }
> if (!defined('WWW_ROOT')) {
> define('WWW_ROOT', APP . $this->params['webroot'] . DS);
> }
> if (!defined('TMP') && !is_dir(APP . 'tmp')) {
> define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 
> 'Templates' . DS . 'skel' . DS . 'tmp' . DS);
> }
> $boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 
> 'bootstrap.php');
> require CORE_PATH . 'Cake' . DS . 'bootstrap.php';
>
> if (!file_exists(APP . 'Config' . DS . 'core.php')) {
> include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 
> 'Templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php';
> App::build();
> }
>
> $this->setErrorHandlers();
>
> if (!defined('FULL_BASE_URL')) {
> $

ShellDispatcher help

2013-11-01 Thread Jared Testa
I'm new to CakePHP.  My first install was 2.4.1, right before .2 came out. 
 I tried using Shell in .1 and got an error.  I also noticed the update the 
same time, so I went ahead and updated to .2.

I'm getting a syntax error when trying to run Console/cake.  

Parse error:  syntax error, unexpected T_STRING, expecting 
T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in 
/home/content/15/10888415/html/flight/lib/Cake/Console/ShellDispatcher.php
 
on line 33

Yes, a simple syntax error.  I HAVE NOT modified anything in the LIB 
directory.  Here is my entire ShellDispatcher.php file:

http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright Copyright (c) Cake Software Foundation, Inc. 
(http://cakefoundation.org)
 * @link  http://cakephp.org CakePHP(tm) Project
 * @since CakePHP(tm) v 2.0
 * @license   http://www.opensource.org/licenses/mit-license.php MIT 
License
 */

/**
 * Shell dispatcher handles dispatching cli commands.
 *
 * @package   Cake.Console
 */
class ShellDispatcher {

/**
 * Contains command switches parsed from the command line.
 *
 * @var array
 */
public $params = array();

/**
 * Contains arguments parsed from the command line.
 *
 * @var array
 */
public $args = array();

/**
 * Constructor
 *
 * The execution of the script is stopped after dispatching the request with
 * a status code of either 0 or 1 according to the result of the dispatch.
 *
 * @param array $args the argv from PHP
 * @param boolean $bootstrap Should the environment be bootstrapped.
 */
public function __construct($args = array(), $bootstrap = true) {
set_time_limit(0);
$this->parseParams($args);

if ($bootstrap) {
$this->_initConstants();
$this->_initEnvironment();
}
}

/**
 * Run the dispatcher
 *
 * @param array $argv The argv from PHP
 * @return void
 */
public static function run($argv) {
$dispatcher = new ShellDispatcher($argv);
return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
}

/**
 * Defines core configuration.
 *
 * @return void
 */
protected function _initConstants() {
if (function_exists('ini_set')) {
ini_set('html_errors', false);
ini_set('implicit_flush', true);
ini_set('max_execution_time', 0);
}

if (!defined('CAKE_CORE_INCLUDE_PATH')) {
define('DS', DIRECTORY_SEPARATOR);
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__;
define('CAKEPHP_SHELL', true);
if (!defined('CORE_PATH')) {
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
}

/**
 * Defines current working environment.
 *
 * @return void
 * @throws CakeException
 */
protected function _initEnvironment() {
if (!$this->_bootstrap()) {
$message = "Unable to load CakePHP core.\nMake sure " . DS . 'lib' . DS . 
'Cake exists in ' . CAKE_CORE_INCLUDE_PATH;
throw new CakeException($message);
}

if (!isset($this->args[0]) || !isset($this->params['working'])) {
$message = "This file has been loaded incorrectly and cannot continue.\n" .
"Please make sure that " . DS . 'lib' . DS . 'Cake' . DS . "Console is in 
your system path,\n" .
"and check the cookbook for the correct usage of this command.\n" .
"(http://book.cakephp.org/)";
throw new CakeException($message);
}

$this->shiftArgs();
}

/**
 * Initializes the environment and loads the CakePHP core.
 *
 * @return boolean Success.
 */
protected function _bootstrap() {
if (!defined('ROOT')) {
define('ROOT', $this->params['root']);
}
if (!defined('APP_DIR')) {
define('APP_DIR', $this->params['app']);
}
if (!defined('APP')) {
define('APP', $this->params['working'] . DS);
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', APP . $this->params['webroot'] . DS);
}
if (!defined('TMP') && !is_dir(APP . 'tmp')) {
define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 
'Templates' . DS . 'skel' . DS . 'tmp' . DS);
}
$boot = file_exists(ROOT . DS . APP_DIR . DS . 'Config' . DS . 
'bootstrap.php');
require CORE_PATH . 'Cake' . DS . 'bootstrap.php';

if (!file_exists(APP . 'Config' . DS . 'core.php')) {
include_once CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 
'Templates' . DS . 'skel' . DS . 'Config' . DS . 'core.php';
App::build();
}

$this->setErrorHandlers();

if (!defined('FULL_BASE_URL')) {
$url = Configure::read('App.fullBaseUrl');
define('FULL_BASE_URL', $url ? $url : 'http://localhost');
Configure::write('App.fullBaseUrl', FULL_BASE_URL);
}

return true;
}

/**
 * Set the error/exception handlers for the console
 * based on the `Error.consoleHandler`, and `Exception.consoleHandler` 
values
 * if they are set. If they are not set, the default ConsoleErrorHandler 
will be
 * used.
 *
 * @return void
 */
public function setErrorHandlers() {
App::uses('ConsoleErrorHandler', 'Console');
$error = Configure::read('Error');
$exception = Configure::read('Exception');

$errorHandler =