Commit f44c565e authored by Taylor Otwell's avatar Taylor Otwell

converted path constants to $GLOBALS.

parent 09d4b74c
......@@ -16,8 +16,8 @@
*/
Autoloader::psr(array(
APP_PATH.'models',
APP_PATH.'libraries',
$GLOBALS['APP_PATH'].'models',
$GLOBALS['APP_PATH'].'libraries',
));
/*
......@@ -37,6 +37,6 @@ Autoloader::psr(array(
*/
Autoloader::map(array(
//'User' => APP_PATH.'models/user.php',
//'Role' => APP_PATH.'models/role.php',
//'User' => $GLOBALS['APP_PATH'].'models/user.php',
//'Role' => $GLOBALS['APP_PATH'].'models/role.php',
));
\ No newline at end of file
......@@ -16,9 +16,9 @@ require 'paths.php';
// --------------------------------------------------------------
// Bootstrap the Laravel core.
// --------------------------------------------------------------
require SYS_PATH.'core.php';
require $GLOBALS['SYS_PATH'].'core.php';
// --------------------------------------------------------------
// Launch the Laravel "Artisan" CLI.
// --------------------------------------------------------------
require SYS_PATH.'cli/artisan'.EXT;
\ No newline at end of file
require $GLOBALS['SYS_PATH'].'cli/artisan'.EXT;
\ No newline at end of file
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
class Asset {
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
class Autoloader {
......@@ -62,7 +62,7 @@ class Autoloader {
if ($namespace == 'Laravel')
{
return static::load_psr($class, BASE_PATH);
return static::load_psr($class, $GLOBALS['BASE_PATH']);
}
// If the class namespace is mapped to a directory, we will load the class
......@@ -149,7 +149,7 @@ class Autoloader {
*
* <code>
* // Register a class mapping with the Autoloader
* Autoloader::map(array('User' => APP_PATH.'models/user.php'));
* Autoloader::map(array('User' => $GLOBALS['APP_PATH'].'models/user.php'));
* </code>
*
* @param array $mappings
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
class Blade {
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
class Bundle {
......@@ -51,7 +51,7 @@ class Bundle {
// We will trim the trailing slash from the location and add it back so
// we don't have to worry about the developer adding or not adding it
// to the location path for the bundle.
$config['location'] = BUNDLE_PATH.rtrim($config['location'], DS).DS;
$config['location'] = $GLOBALS['BUNDLE_PATH'].rtrim($config['location'], DS).DS;
static::$bundles[$bundle] = array_merge($defaults, $config);
}
......@@ -173,7 +173,7 @@ class Bundle {
* // Returns the bundle path for the "admin" bundle
* $path = Bundle::path('admin');
*
* // Returns the APP_PATH constant as the default bundle
* // Returns the $GLOBALS['APP_PATH'] constant as the default bundle
* $path = Bundle::path('application');
* </code>
*
......@@ -182,7 +182,7 @@ class Bundle {
*/
public static function path($bundle)
{
return ($bundle == DEFAULT_BUNDLE) ? APP_PATH : static::$bundles[$bundle]['location'];
return ($bundle == DEFAULT_BUNDLE) ? $GLOBALS['APP_PATH'] : static::$bundles[$bundle]['location'];
}
/**
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
class Cache {
......@@ -51,7 +51,7 @@ class Cache {
return new Cache\Drivers\APC(Config::get('cache.key'));
case 'file':
return new Cache\Drivers\File(CACHE_PATH);
return new Cache\Drivers\File($GLOBALS['STORAGE_PATH'].'cache'.DS);
case 'memcached':
return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key'));
......
<?php namespace Laravel\CLI; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel\CLI; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
use Laravel\Bundle;
use Laravel\Config;
......@@ -44,7 +44,7 @@ if (isset($_SERVER['cli']['db']))
* us to seamlessly add tasks to the CLI so that the Task class
* doesn't have to worry about how to resolve core tasks.
*/
require SYS_PATH.'cli/dependencies'.EXT;
require $GLOBALS['SYS_PATH'].'cli/dependencies'.EXT;
/**
* We will wrap the command execution in a try / catch block and
......
<?php namespace Laravel\CLI\Tasks\Bundle; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel\CLI\Tasks\Bundle; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
use Laravel\IoC;
use Laravel\Bundle;
......@@ -16,7 +16,7 @@ class Bundler extends Task {
{
foreach ($this->get($bundles) as $bundle)
{
if (is_dir(BUNDLE_PATH.$bundle['name']))
if (is_dir($GLOBALS['BUNDLE_PATH'].$bundle['name']))
{
echo "Bundle {$bundle['name']} is already installed.";
......
......@@ -17,7 +17,7 @@ class Github implements Provider {
// a location outside of the Git repository, so we don't need
// the full bundle path. We'll just take the basename in case
// the bundle directory has been renamed.
$path = basename(BUNDLE_PATH).'/';
$path = basename($GLOBALS['BUNDLE_PATH']).'/';
passthru('git submodule add '.$repository.' '.$path.$bundle['name']);
......
......@@ -16,7 +16,7 @@ class Publisher {
{
$path = Bundle::path($bundle);
$this->move($path.'public', PUBLIC_PATH.'bundles'.DS.$bundle);
$this->move($path.'public', $GLOBALS['PUBLIC_PATH'].'bundles'.DS.$bundle);
echo "Assets published for bundle [$bundle].".PHP_EOL;
}
......@@ -41,7 +41,7 @@ class Publisher {
*/
protected function to($bundle)
{
return PUBLIC_PATH.'bundles'.DS.$bundle.DS;
return $GLOBALS['PUBLIC_PATH'].'bundles'.DS.$bundle.DS;
}
/**
......
......@@ -19,7 +19,7 @@ class Key extends Task {
*/
public function __construct()
{
$this->path = APP_PATH.'config/application'.EXT;
$this->path = $GLOBALS['APP_PATH'].'config/application'.EXT;
}
/**
......
......@@ -222,7 +222,7 @@ class Migrator extends Task {
*/
protected function stub($bundle, $migration)
{
$stub = File::get(SYS_PATH.'cli/tasks/migrate/stub'.EXT);
$stub = File::get($GLOBALS['SYS_PATH'].'cli/tasks/migrate/stub'.EXT);
// The class name is formatted simialrly to tasks and controllers,
// where the bundle name is prefixed to the class if it is not in
......
......@@ -34,7 +34,7 @@ class Manager extends Task {
// generated on the database.
$migration = $migrator->make(array('create_session_table'));
$stub = SYS_PATH.'cli/tasks/session/migration'.EXT;
$stub = $GLOBALS['SYS_PATH'].'cli/tasks/session/migration'.EXT;
File::put($migration, File::get($stub));
......@@ -42,7 +42,7 @@ class Manager extends Task {
// Since the developer is requesting that the session table be
// created on the database, we'll set the driver to database
// to save an extra step for the developer.
$config = File::get(APP_PATH.'config/session'.EXT);
$config = File::get($GLOBALS['APP_PATH'].'config/session'.EXT);
$config = str_replace(
"'driver' => '',",
......@@ -50,7 +50,7 @@ class Manager extends Task {
$config
);
File::put(APP_PATH.'config/session'.EXT, $config);
File::put($GLOBALS['APP_PATH'].'config/session'.EXT, $config);
echo PHP_EOL;
......
......@@ -23,7 +23,7 @@ class Runner extends Task {
*/
public function core()
{
if ( ! is_dir(BUNDLE_PATH.'laravel-tests'))
if ( ! is_dir($GLOBALS['BUNDLE_PATH'].'laravel-tests'))
{
throw new \Exception("The bundle [laravel-tests] has not been installed!");
}
......@@ -31,7 +31,19 @@ class Runner extends Task {
// When testing the Laravel core, we will just stub the path directly
// so the test bundle is not required to be registered in the bundle
// configuration, as it is kind of a unique bundle.
$this->stub(BUNDLE_PATH.'laravel-tests/cases');
$this->stub($GLOBALS['BUNDLE_PATH'].'laravel-tests/cases');
$path = $GLOBALS['BUNDLE_PATH'].'laravel-tests/';
// When testing the framework, we will swap out the application
// and other core paths to stub out the application portion of
// the framework for testing. This allows us to create dummy
// controllers, views, models, etc.
$GLOBALS['APP_PATH'] = $path.'application'.DS;
$GLOBALS['BUNDLE_PATH'] = $path.'bundles'.DS;
$GLOBALS['STORAGE_PATH'] = $path.'storage'.DS;
$this->test();
}
......@@ -74,9 +86,9 @@ class Runner extends Task {
// We'll simply fire off PHPUnit with the configuration switch
// pointing to our temporary configuration file. This allows
// us to flexibly run tests for any setup.
passthru('phpunit -c '.BASE_PATH.'phpunit.xml');
passthru('phpunit -c '.$GLOBALS['BASE_PATH'].'phpunit.xml');
@unlink(BASE_PATH.'phpunit.xml');
@unlink($GLOBALS['BASE_PATH'].'phpunit.xml');
}
/**
......@@ -87,11 +99,11 @@ class Runner extends Task {
*/
protected function stub($directory)
{
$stub = File::get(SYS_PATH.'cli/tasks/test/stub.xml');
$stub = File::get($GLOBALS['SYS_PATH'].'cli/tasks/test/stub.xml');
$stub = str_replace('{{directory}}', $directory, $stub);
File::put(BASE_PATH.'phpunit.xml', $stub);
File::put($GLOBALS['BASE_PATH'].'phpunit.xml', $stub);
}
}
\ No newline at end of file
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
use Closure;
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
use Closure;
......
......@@ -9,9 +9,6 @@
define('EXT', '.php');
define('CRLF', "\r\n");
define('BLADE_EXT', '.blade.php');
define('CACHE_PATH', STORAGE_PATH.'cache'.DS);
define('DATABASE_PATH', STORAGE_PATH.'database'.DS);
define('SESSION_PATH', STORAGE_PATH.'sessions'.DS);
define('DEFAULT_BUNDLE', 'application');
define('MB_STRING', (int) function_exists('mb_get_info'));
......@@ -20,10 +17,10 @@ define('MB_STRING', (int) function_exists('mb_get_info'));
* These are typically classes that the auto-loader relies upon to
* load classes, such as the array and configuration classes.
*/
require SYS_PATH.'bundle'.EXT;
require SYS_PATH.'config'.EXT;
require SYS_PATH.'helpers'.EXT;
require SYS_PATH.'autoloader'.EXT;
require $GLOBALS['SYS_PATH'].'bundle'.EXT;
require $GLOBALS['SYS_PATH'].'config'.EXT;
require $GLOBALS['SYS_PATH'].'helpers'.EXT;
require $GLOBALS['SYS_PATH'].'autoloader'.EXT;
/**
* Register the Autoloader's "load" method on the auto-loader stack.
......@@ -45,7 +42,7 @@ Autoloader::$aliases = Config::get('application.aliases');
* file within the bundles directory. This informs the framework
* where the bundle lives and which URIs it responds to.
*/
$bundles = require BUNDLE_PATH.'bundles'.EXT;
$bundles = require $GLOBALS['BUNDLE_PATH'].'bundles'.EXT;
foreach ($bundles as $bundle => $value)
{
......
<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
<?php namespace Laravel; isset($GLOBALS['APP_PATH']) or die('No direct script access.');
if (trim(Config::get('application.key')) === '')
{
......
......@@ -24,7 +24,7 @@ class SQLite extends Connector {
// SQLite databases will be created automatically if they do not exist, so we
// will not check for the existence of the database file before establishing
// the PDO connection to the database.
$path = DATABASE_PATH.$config['database'].'.sqlite';
$path = $GLOBALS['STORAGE_PATH'].'database'.DS.$config['database'].'.sqlite';
return new PDO('sqlite:'.$path, null, null, $options);
}
......
......@@ -18,10 +18,10 @@ class File {
*
* <code>
* // Get the contents of a file
* $contents = File::get(APP_PATH.'routes'.EXT);
* $contents = File::get($GLOBALS['APP_PATH'].'routes'.EXT);
*
* // Get the contents of a file or return a default value if it doesn't exist
* $contents = File::get(APP_PATH.'routes'.EXT, 'Default Value');
* $contents = File::get($GLOBALS['APP_PATH'].'routes'.EXT, 'Default Value');
* </code>
*
* @param string $path
......
<?php
/**
* Get one of the global paths.
*
* @param string $path
* @return string
*/
function path($path)
{
return $GLOBALS[strtoupper($path).'_PATH'];
}
/**
* Convert HTML characters to entities.
*
......@@ -268,7 +279,7 @@ function head($array)
* @param bool $https
* @return string
*/
function path($url = '', $https = false)
function url($url = '', $https = false)
{
return Laravel\URL::to($url, $https);
}
......
......@@ -43,7 +43,7 @@ class Log {
{
$message = date('Y-m-d H:i:s').' '.Str::upper($type)." - {$message}".PHP_EOL;
File::append(STORAGE_PATH.'logs/'.date('Y-m-d').'.log', $message);
File::append($GLOBALS['STORAGE_PATH'].'logs/'.date('Y-m-d').'.log', $message);
}
/**
......
......@@ -52,7 +52,7 @@ class Session {
return new Session\Drivers\Database(Database::connection());
case 'file':
return new Session\Drivers\File(SESSION_PATH);
return new Session\Drivers\File($GLOBALS['STORAGE_PATH'].'sessions'.DS);
case 'memcached':
return new Session\Drivers\Memcached(Cache::driver('memcached'));
......
......@@ -261,7 +261,7 @@ class View implements ArrayAccess {
// hash of their path. This allows us to easily store the views in
// the directory without worrying about re-creating the entire
// application view directory structure.
$compiled = STORAGE_PATH.'views/'.md5($this->path);
$compiled = $GLOBALS['STORAGE_PATH'].'views/'.md5($this->path);
// The view will only be re-compiled if the view has been modified
// since the last compiled version of the view was created or no
......
......@@ -24,7 +24,7 @@ if ( ! defined('DS'))
// --------------------------------------------------------------
// Define the path to the base directory.
// --------------------------------------------------------------
define('BASE_PATH', __DIR__.DS);
$GLOBALS['BASE_PATH'] = __DIR__.DS;
// --------------------------------------------------------------
// The path to the application directory.
......@@ -46,21 +46,16 @@ $paths['BUNDLE_PATH'] = 'bundles';
// --------------------------------------------------------------
$paths['STORAGE_PATH'] = 'storage';
// --------------------------------------------------------------
// The path to the tests directory.
// --------------------------------------------------------------
$paths['TESTS_PATH'] = 'tests';
// --------------------------------------------------------------
// The path to the public directory.
// --------------------------------------------------------------
if ($web)
{
define('PUBLIC_PATH', realpath('').DS);
$GLOBALS['PUBLIC_PATH'] = realpath('').DS;
}
else
{
$paths['PUBLIC_PATH'] = 'public';
$paths['PUBLIC'] = 'public';
}
// --------------------------------------------------------------
......@@ -68,10 +63,7 @@ else
// --------------------------------------------------------------
foreach ($paths as $name => $path)
{
if ( ! defined($name))
{
if ($web) $path = "../{$path}";
if ($web) $path = "../{$path}";
define($name, realpath($path).DS);
}
$GLOBALS[$name] = realpath($path).DS;
}
\ No newline at end of file
......@@ -13,21 +13,6 @@
// --------------------------------------------------------------
define('DS', DIRECTORY_SEPARATOR);
// --------------------------------------------------------------
// Override the framework paths if testing Laravel.
// --------------------------------------------------------------
foreach ($_SERVER['argv'] as $argument)
{
if (strpos($argument, 'build.xml') !== false)
{
define('APP_PATH', realpath('bundles/laravel-tests/application').DS);
define('BUNDLE_PATH', realpath('bundles/laravel-tests/bundles').DS);
define('STORAGE_PATH', realpath('bundles/laravel-tests/storage').DS);
}
}
// --------------------------------------------------------------
// Set the core Laravel path constants.
// --------------------------------------------------------------
......@@ -36,7 +21,7 @@ require 'paths.php';
// --------------------------------------------------------------
// Bootstrap the Laravel core.
// --------------------------------------------------------------
require SYS_PATH.'core.php';
require $GLOBALS['SYS_PATH'].'core.php';
// --------------------------------------------------------------
// Start the default bundle.
......
......@@ -31,4 +31,4 @@ unset($web);
// --------------------------------------------------------------
// Launch Laravel.
// --------------------------------------------------------------
require SYS_PATH.'laravel.php';
\ No newline at end of file
require $GLOBALS['SYS_PATH'].'laravel.php';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment