first commit of 2.0
This commit is contained in:
parent
119b356bde
commit
1e90e42404
|
@ -1,48 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
return array(
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Class Aliases
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Here, you can specify any class aliases that you would like registered
|
|
||||||
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
|
||||||
|
|
|
||||||
| Aliases make it more convenient to use namespaced classes. Instead of
|
|
||||||
| referring to the class using its full namespace, you may simply use
|
|
||||||
| the alias defined here.
|
|
||||||
|
|
|
||||||
| We have already aliased common Laravel classes to make your life easier.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'Asset' => 'System\\Asset',
|
|
||||||
'Auth' => 'System\\Auth',
|
|
||||||
'Benchmark' => 'System\\Benchmark',
|
|
||||||
'Cache' => 'System\\Cache',
|
|
||||||
'Config' => 'System\\Config',
|
|
||||||
'Cookie' => 'System\\Cookie',
|
|
||||||
'Crypter' => 'System\\Crypter',
|
|
||||||
'DB' => 'System\\DB',
|
|
||||||
'Eloquent' => 'System\\DB\\Eloquent\\Model',
|
|
||||||
'File' => 'System\\File',
|
|
||||||
'Form' => 'System\\Form',
|
|
||||||
'Hash' => 'System\\Hash',
|
|
||||||
'HTML' => 'System\\HTML',
|
|
||||||
'Inflector' => 'System\\Inflector',
|
|
||||||
'Input' => 'System\\Input',
|
|
||||||
'Lang' => 'System\\Lang',
|
|
||||||
'Loader' => 'System\\Loader',
|
|
||||||
'Package' => 'System\\Package',
|
|
||||||
'URL' => 'System\\URL',
|
|
||||||
'Redirect' => 'System\\Redirect',
|
|
||||||
'Request' => 'System\\Request',
|
|
||||||
'Response' => 'System\\Response',
|
|
||||||
'Session' => 'System\\Session',
|
|
||||||
'Str' => 'System\\Str',
|
|
||||||
'Validator' => 'System\\Validator',
|
|
||||||
'View' => 'System\\View',
|
|
||||||
|
|
||||||
);
|
|
|
@ -81,7 +81,7 @@
|
||||||
|
|
||||||
<h2><?php echo $apology; ?></h2>
|
<h2><?php echo $apology; ?></h2>
|
||||||
|
|
||||||
<p>We couldn't find the resource you requested. Would you like go to our <a href="<?php echo System\Config::get('application.url'); ?>">home page</a> instead?</p>
|
<p>We couldn't find the resource you requested. Would you like go to our <a href="<?php echo Laravel\Config::get('application.url'); ?>">home page</a> instead?</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -81,7 +81,7 @@
|
||||||
|
|
||||||
<h2><?php echo $apology; ?></h2>
|
<h2><?php echo $apology; ?></h2>
|
||||||
|
|
||||||
<p>Something failed while we were handling your request. Would you like go to our <a href="<?php echo System\Config::get('application.url'); ?>">home page</a> instead?</p>
|
<p>Something failed while we were handling your request. Would you like go to our <a href="<?php echo Laravel\Config::get('application.url'); ?>">home page</a> instead?</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,14 +1,5 @@
|
||||||
# Laravel Change Log
|
# Laravel Change Log
|
||||||
|
|
||||||
## Version 1.5.3
|
|
||||||
|
|
||||||
- Various bug fixes.
|
|
||||||
- Allow columns to be specified on Eloquent queries.
|
|
||||||
|
|
||||||
### Upgrading From 1.5.2
|
|
||||||
|
|
||||||
- Replace **system** directory.
|
|
||||||
|
|
||||||
## Version 1.5.2
|
## Version 1.5.2
|
||||||
|
|
||||||
- Moved **system/db/manager.php** to **system/db.php**. Updated alias appropriately.
|
- Moved **system/db/manager.php** to **system/db.php**. Updated alias appropriately.
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Class Aliases
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here, you can specify any class aliases that you would like registered
|
||||||
|
| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
|
||||||
|
|
|
||||||
|
| Aliases make it more convenient to use namespaced classes. Instead of
|
||||||
|
| referring to the class using its full namespace, you may simply use
|
||||||
|
| the alias defined here.
|
||||||
|
|
|
||||||
|
| We have already aliased common Laravel classes to make your life easier.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'Asset' => 'Laravel\\Asset',
|
||||||
|
'Auth' => 'Laravel\\Auth',
|
||||||
|
'Benchmark' => 'Laravel\\Benchmark',
|
||||||
|
'Cache' => 'Laravel\\Cache',
|
||||||
|
'Config' => 'Laravel\\Config',
|
||||||
|
'Cookie' => 'Laravel\\Cookie',
|
||||||
|
'Crypter' => 'Laravel\\Crypter',
|
||||||
|
'DB' => 'Laravel\\DB',
|
||||||
|
'Eloquent' => 'Laravel\\DB\\Eloquent\\Model',
|
||||||
|
'File' => 'Laravel\\File',
|
||||||
|
'Form' => 'Laravel\\Form',
|
||||||
|
'Hash' => 'Laravel\\Hash',
|
||||||
|
'HTML' => 'Laravel\\HTML',
|
||||||
|
'Inflector' => 'Laravel\\Inflector',
|
||||||
|
'Input' => 'Laravel\\Input',
|
||||||
|
'Lang' => 'Laravel\\Lang',
|
||||||
|
'Loader' => 'Laravel\\Loader',
|
||||||
|
'Package' => 'Laravel\\Package',
|
||||||
|
'URL' => 'Laravel\\URL',
|
||||||
|
'Redirect' => 'Laravel\\Redirect',
|
||||||
|
'Request' => 'Laravel\\Request',
|
||||||
|
'Response' => 'Laravel\\Response',
|
||||||
|
'Session' => 'Laravel\\Session',
|
||||||
|
'Str' => 'Laravel\\Str',
|
||||||
|
'Validator' => 'Laravel\\Validator',
|
||||||
|
'View' => 'Laravel\\View',
|
||||||
|
|
||||||
|
);
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'url' => 'http://localhost',
|
'url' => 'http://beta.laravel.com',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
@ -82,23 +82,6 @@
|
||||||
|
|
||||||
'packages' => array(),
|
'packages' => array(),
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Active Modules
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Modules are a convenient way to organize your application into logical
|
|
||||||
| components. Each module may have its own libraries, models, routes,
|
|
||||||
| views, language files, and configuration.
|
|
||||||
|
|
|
||||||
| Here you may specify which modules are "active" for your application.
|
|
||||||
| This simply gives Laravel an easy way to know which directories to
|
|
||||||
| check when auto-loading your classes, routes, and views.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
'modules' => array(),
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Application Key
|
| Application Key
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Arr {
|
class Arr {
|
||||||
|
|
||||||
|
@ -9,6 +9,11 @@ class Arr {
|
||||||
* also be accessed using JavaScript "dot" style notation. Retrieving items nested
|
* also be accessed using JavaScript "dot" style notation. Retrieving items nested
|
||||||
* in multiple arrays is also supported.
|
* in multiple arrays is also supported.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Returns "taylor"
|
||||||
|
* Arr::get(array('name' => array('is' => 'Taylor')), 'name.is');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $default
|
* @param mixed $default
|
||||||
|
@ -37,8 +42,16 @@ public static function get($array, $key, $default = null)
|
||||||
* This method is primarly helpful for setting the value in an array with
|
* This method is primarly helpful for setting the value in an array with
|
||||||
* a variable depth, such as configuration arrays.
|
* a variable depth, such as configuration arrays.
|
||||||
*
|
*
|
||||||
|
* If the specified item doesn't exist, it will be created. If the item's
|
||||||
|
* parents do no exist, they will also be created as arrays.
|
||||||
|
*
|
||||||
* Like the Arr::get method, JavaScript "dot" syntax is supported.
|
* Like the Arr::get method, JavaScript "dot" syntax is supported.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Set "name.is" to "taylor"
|
||||||
|
* Arr::set(array('name' => array('is' => 'something')), 'name.is', 'taylor');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
|
@ -1,7 +1,7 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
use System\File;
|
use Laravel\File;
|
||||||
use System\HTML;
|
use Laravel\HTML;
|
||||||
|
|
||||||
class Asset {
|
class Asset {
|
||||||
|
|
||||||
|
@ -21,6 +21,14 @@ class Asset {
|
||||||
* Containers provide a convenient method of grouping assets while maintaining
|
* Containers provide a convenient method of grouping assets while maintaining
|
||||||
* expressive code and a clean API.
|
* expressive code and a clean API.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get the default asset container
|
||||||
|
* $container = Asset::container();
|
||||||
|
*
|
||||||
|
* // Get the "footer" asset container
|
||||||
|
* $container = Asset::container('footer');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $container
|
* @param string $container
|
||||||
* @return Asset_Container
|
* @return Asset_Container
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +44,17 @@ public static function container($container = 'default')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic Method for calling methods on the default Asset container.
|
* Magic Method for calling methods on the default Asset container.
|
||||||
|
*
|
||||||
|
* This provides a convenient API, allowing the develop to skip the "container"
|
||||||
|
* method when using the default container.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Add an asset to the default container
|
||||||
|
* Asset::add('jquery', 'js/jquery.js');
|
||||||
|
*
|
||||||
|
* // Equivalent statement using the container method
|
||||||
|
* Asset::container()->add('jquery', 'js/jquery.js');
|
||||||
|
* </code>
|
||||||
*/
|
*/
|
||||||
public static function __callStatic($method, $parameters)
|
public static function __callStatic($method, $parameters)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +68,8 @@ class Asset_Container {
|
||||||
/**
|
/**
|
||||||
* The asset container name.
|
* The asset container name.
|
||||||
*
|
*
|
||||||
|
* This name may be used to access the container instance via the Asset::container method.
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $name;
|
public $name;
|
||||||
|
@ -82,6 +103,14 @@ public function __construct($name)
|
||||||
* only link to the registered asset after its dependencies have been linked.
|
* only link to the registered asset after its dependencies have been linked.
|
||||||
* For example, you may wish to make jQuery UI dependent on jQuery.
|
* For example, you may wish to make jQuery UI dependent on jQuery.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Add an asset to the container
|
||||||
|
* Asset::container()->add('jquery', 'js/jquery.js');
|
||||||
|
*
|
||||||
|
* // Add an asset that is dependent on another asset
|
||||||
|
* Asset::container()->add('jquery-ui', 'js/jquery-ui.js', array('jquery'));
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $source
|
* @param string $source
|
||||||
* @param array $dependencies
|
* @param array $dependencies
|
||||||
|
@ -103,7 +132,6 @@ public function add($name, $source, $dependencies = array(), $attributes = array
|
||||||
* @param array $dependencies
|
* @param array $dependencies
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @return void
|
* @return void
|
||||||
* @see add
|
|
||||||
*/
|
*/
|
||||||
public function style($name, $source, $dependencies = array(), $attributes = array())
|
public function style($name, $source, $dependencies = array(), $attributes = array())
|
||||||
{
|
{
|
||||||
|
@ -123,7 +151,6 @@ public function style($name, $source, $dependencies = array(), $attributes = arr
|
||||||
* @param array $dependencies
|
* @param array $dependencies
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @return void
|
* @return void
|
||||||
* @see add
|
|
||||||
*/
|
*/
|
||||||
public function script($name, $source, $dependencies = array(), $attributes = array())
|
public function script($name, $source, $dependencies = array(), $attributes = array())
|
||||||
{
|
{
|
||||||
|
@ -131,7 +158,9 @@ public function script($name, $source, $dependencies = array(), $attributes = ar
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an asset to the registered assets.
|
* Add an asset to the array of registered assets.
|
||||||
|
*
|
||||||
|
* Assets are organized in the array by type (CSS or JavaScript).
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
@ -150,6 +179,10 @@ private function register($type, $name, $source, $dependencies, $attributes)
|
||||||
/**
|
/**
|
||||||
* Get the links to all of the registered CSS assets.
|
* Get the links to all of the registered CSS assets.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* echo Asset::container()->styles();
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function styles()
|
public function styles()
|
||||||
|
@ -160,6 +193,10 @@ public function styles()
|
||||||
/**
|
/**
|
||||||
* Get the links to all of the registered JavaScript assets.
|
* Get the links to all of the registered JavaScript assets.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* echo Asset::container()->scripts();
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function scripts()
|
public function scripts()
|
||||||
|
@ -168,7 +205,7 @@ public function scripts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all of the registered assets for a given group.
|
* Get all of the registered assets for a given type / group.
|
||||||
*
|
*
|
||||||
* @param string $group
|
* @param string $group
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -190,6 +227,10 @@ private function get_group($group)
|
||||||
/**
|
/**
|
||||||
* Get the link to a single registered CSS asset.
|
* Get the link to a single registered CSS asset.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* echo Asset::container()->get_style('common');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -201,6 +242,10 @@ public function get_style($name)
|
||||||
/**
|
/**
|
||||||
* Get the link to a single registered JavaScript asset.
|
* Get the link to a single registered JavaScript asset.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* echo Asset::container()->get_script('jquery');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -210,7 +255,7 @@ public function get_script($name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a registered asset.
|
* Get the HTML link to a registered asset.
|
||||||
*
|
*
|
||||||
* @param string $group
|
* @param string $group
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
@ -287,7 +332,10 @@ private function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that a dependency is valid.
|
* Verify that an asset's dependency is valid.
|
||||||
|
*
|
||||||
|
* A dependency is considered valid if it exists, is not a circular reference, and is
|
||||||
|
* not a reference to the owning asset itself.
|
||||||
*
|
*
|
||||||
* @param string $asset
|
* @param string $asset
|
||||||
* @param string $dependency
|
* @param string $dependency
|
||||||
|
@ -297,11 +345,9 @@ private function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||||
*/
|
*/
|
||||||
private function dependency_is_valid($asset, $dependency, $original, $assets)
|
private function dependency_is_valid($asset, $dependency, $original, $assets)
|
||||||
{
|
{
|
||||||
if ( ! isset($original[$dependency]))
|
if ( ! isset($original[$dependency])) return false;
|
||||||
{
|
|
||||||
return false;
|
if ($dependency === $asset)
|
||||||
}
|
|
||||||
elseif ($dependency === $asset)
|
|
||||||
{
|
{
|
||||||
throw new \Exception("Asset [$asset] is dependent on itself.");
|
throw new \Exception("Asset [$asset] is dependent on itself.");
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
if (Config::get('session.driver') == '')
|
if (Config::get('session.driver') == '')
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@ class Auth {
|
||||||
/**
|
/**
|
||||||
* Determine if the current user of the application is authenticated.
|
* Determine if the current user of the application is authenticated.
|
||||||
*
|
*
|
||||||
|
* @see login()
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function check()
|
public static function check()
|
||||||
|
@ -43,8 +44,11 @@ public static function check()
|
||||||
* the "by_id" closure in the authentication configuration file. The result
|
* the "by_id" closure in the authentication configuration file. The result
|
||||||
* of the closure will be cached and returned.
|
* of the closure will be cached and returned.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* $email = Auth::user()->email;
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @return object
|
* @return object
|
||||||
* @see $user
|
|
||||||
*/
|
*/
|
||||||
public static function user()
|
public static function user()
|
||||||
{
|
{
|
||||||
|
@ -65,6 +69,13 @@ public static function user()
|
||||||
* The password passed to the method should be plain text, as it will be hashed
|
* The password passed to the method should be plain text, as it will be hashed
|
||||||
* by the Hash class when authenticating.
|
* by the Hash class when authenticating.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* if (Auth::login('email@example.com', 'password'))
|
||||||
|
* {
|
||||||
|
* // The credentials are valid and the user is now logged in.
|
||||||
|
* }
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -88,7 +99,8 @@ public static function login($username, $password)
|
||||||
* Log a user into your application.
|
* Log a user into your application.
|
||||||
*
|
*
|
||||||
* The user's ID will be stored in the session and the user will be considered
|
* The user's ID will be stored in the session and the user will be considered
|
||||||
* "logged in" on subsequent requests to your application.
|
* "logged in" on subsequent requests to your application. This method is called
|
||||||
|
* by the login method after determining a user's credentials are valid.
|
||||||
*
|
*
|
||||||
* Note: The user given to this method should be an object having an "id" property.
|
* Note: The user given to this method should be an object having an "id" property.
|
||||||
*
|
*
|
||||||
|
@ -106,7 +118,7 @@ public static function remember($user)
|
||||||
* Log the user out of your application.
|
* Log the user out of your application.
|
||||||
*
|
*
|
||||||
* The user ID will be removed from the session and the user will no longer
|
* The user ID will be removed from the session and the user will no longer
|
||||||
* be considered logged in on subsequent requests.
|
* be considered logged in on subsequent requests to your application.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Benchmark {
|
class Benchmark {
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ class Benchmark {
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return void
|
||||||
* @see check
|
|
||||||
*/
|
*/
|
||||||
public static function start($name)
|
public static function start($name)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +28,6 @@ public static function start($name)
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return float
|
* @return float
|
||||||
* @see start
|
|
||||||
*/
|
*/
|
||||||
public static function check($name)
|
public static function check($name)
|
||||||
{
|
{
|
|
@ -0,0 +1,70 @@
|
||||||
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Cache {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All of the active cache drivers.
|
||||||
|
*
|
||||||
|
* @var Cache\Driver
|
||||||
|
*/
|
||||||
|
public static $drivers = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a cache driver instance.
|
||||||
|
*
|
||||||
|
* If no driver name is specified, the default cache driver will be returned
|
||||||
|
* as defined in the cache configuration file.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get the default cache driver
|
||||||
|
* $driver = Cache::driver();
|
||||||
|
*
|
||||||
|
* // Get the APC cache driver
|
||||||
|
* $apc = Cache::driver('apc');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $driver
|
||||||
|
* @return Cache\Driver
|
||||||
|
*/
|
||||||
|
public static function driver($driver = null)
|
||||||
|
{
|
||||||
|
if (is_null($driver)) $driver = Config::get('cache.driver');
|
||||||
|
|
||||||
|
if ( ! array_key_exists($driver, static::$drivers))
|
||||||
|
{
|
||||||
|
switch ($driver)
|
||||||
|
{
|
||||||
|
case 'file':
|
||||||
|
return static::$drivers[$driver] = new Cache\File;
|
||||||
|
|
||||||
|
case 'memcached':
|
||||||
|
return static::$drivers[$driver] = new Cache\Memcached;
|
||||||
|
|
||||||
|
case 'apc':
|
||||||
|
return static::$drivers[$driver] = new Cache\APC;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \Exception("Cache driver [$driver] is not supported.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return static::$drivers[$driver];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass all other methods to the default driver.
|
||||||
|
*
|
||||||
|
* Passing method calls to the driver instance provides a convenient API for the developer
|
||||||
|
* when always using the default cache driver.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get an item from the default cache driver
|
||||||
|
* $name = Cache::get('name');
|
||||||
|
* </code>
|
||||||
|
*/
|
||||||
|
public static function __callStatic($method, $parameters)
|
||||||
|
{
|
||||||
|
return call_user_func_array(array(static::driver(), $method), $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php namespace Laravel\Cache;
|
||||||
|
|
||||||
|
use Laravel\Config;
|
||||||
|
|
||||||
|
class APC extends Driver {
|
||||||
|
|
||||||
|
public function has($key)
|
||||||
|
{
|
||||||
|
return ( ! is_null($this->get($key)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key, $default = null)
|
||||||
|
{
|
||||||
|
$item = ( ! is_null($cache = apc_fetch(Config::get('cache.key').$key))) ? $cache : null;
|
||||||
|
|
||||||
|
return $this->prepare($item, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put($key, $value, $minutes)
|
||||||
|
{
|
||||||
|
apc_store(Config::get('cache.key').$key, $value, $minutes * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forget($key)
|
||||||
|
{
|
||||||
|
apc_delete(Config::get('cache.key').$key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
<?php namespace Laravel\Cache;
|
||||||
|
|
||||||
|
abstract class Driver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if an item exists in the cache.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
abstract public function has($key);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an item from the cache.
|
||||||
|
*
|
||||||
|
* A default value may also be specified, and will be returned in the requested
|
||||||
|
* item does not exist in the cache.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get the "name" item from the cache
|
||||||
|
* $name = Cache::driver()->get('name');
|
||||||
|
*
|
||||||
|
* // Get the "name" item from the cache or return "Fred"
|
||||||
|
* $name = Cache::driver()->get('name', 'Fred');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @param string $driver
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
abstract public function get($key, $default = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the cache item for returning to the requestor.
|
||||||
|
*
|
||||||
|
* If the item is NULL, the default will be returned.
|
||||||
|
*
|
||||||
|
* @param mixed $item
|
||||||
|
* @param mixed $default
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
protected function prepare($item, $default)
|
||||||
|
{
|
||||||
|
if ( ! is_null($item)) return $item;
|
||||||
|
|
||||||
|
return (is_callable($default)) ? call_user_func($default) : $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write an item to the cache.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @param int $minutes
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract public function put($key, $value, $minutes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an item from the cache. If the item doesn't exist in the cache, store
|
||||||
|
* the default value in the cache and return it.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get the "name" item from the cache or store "Fred" for 30 minutes
|
||||||
|
* $name = Cache::driver()->remember('name', 'Fred', 30);
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $default
|
||||||
|
* @param int $minutes
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function remember($key, $value, $minutes)
|
||||||
|
{
|
||||||
|
if ( ! is_null($item = $this->get($key, null, $driver))) return $item;
|
||||||
|
|
||||||
|
$default = is_callable($default) ? call_user_func($default) : $default;
|
||||||
|
|
||||||
|
$this->put($key, $default, $minutes);
|
||||||
|
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete an item from the cache.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
abstract public function forget($key);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
<?php namespace Laravel\Cache;
|
||||||
|
|
||||||
|
class File extends Driver {
|
||||||
|
|
||||||
|
public function has($key)
|
||||||
|
{
|
||||||
|
return ( ! is_null($this->get($key)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key, $default = null)
|
||||||
|
{
|
||||||
|
if ( ! file_exists(CACHE_PATH.$key))
|
||||||
|
{
|
||||||
|
return $this->prepare(null, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache = file_get_contents(CACHE_PATH.$key);
|
||||||
|
|
||||||
|
// The cache expiration date is stored as a UNIX timestamp at the beginning
|
||||||
|
// of the cache file. We'll extract it out and check it here.
|
||||||
|
if (time() >= substr($cache, 0, 10))
|
||||||
|
{
|
||||||
|
$this->forget($key);
|
||||||
|
|
||||||
|
return $this->prepare(null, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->prepare(unserialize(substr($cache, 10)), $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put($key, $value, $minutes)
|
||||||
|
{
|
||||||
|
file_put_contents(CACHE_PATH.$key, (time() + ($minutes * 60)).serialize($value), LOCK_EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forget($key)
|
||||||
|
{
|
||||||
|
@unlink(CACHE_PATH.$key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php namespace Laravel\Cache;
|
||||||
|
|
||||||
|
use Laravel\Config;
|
||||||
|
use Laravel\Memcached as Mem;
|
||||||
|
|
||||||
|
class Memcached extends Driver {
|
||||||
|
|
||||||
|
public function has($key)
|
||||||
|
{
|
||||||
|
return ( ! is_null($this->get($key)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key, $default = null)
|
||||||
|
{
|
||||||
|
$item = (($cache = Mem::instance()->get(Config::get('cache.key').$key)) !== false) ? $cache : null;
|
||||||
|
|
||||||
|
return $this->prepare($item, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put($key, $value, $minutes)
|
||||||
|
{
|
||||||
|
Mem::instance()->set(Config::get('cache.key').$key, $value, 0, $minutes * 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forget($key)
|
||||||
|
{
|
||||||
|
Mem::instance()->delete(Config::get('cache.key').$key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,170 @@
|
||||||
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All of the loaded configuration items.
|
||||||
|
*
|
||||||
|
* The configuration arrays are keyed by module and file names.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $items = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a configuration item or file exists.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Determine if the "session" configuration file exists
|
||||||
|
* Config::has('session');
|
||||||
|
*
|
||||||
|
* // Determine if the application timezone option exists
|
||||||
|
* Config::has('application.timezone');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function has($key)
|
||||||
|
{
|
||||||
|
return ! is_null(static::get($key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a configuration item.
|
||||||
|
*
|
||||||
|
* Configuration items are retrieved using "dot" notation. So, asking for the
|
||||||
|
* "application.timezone" configuration item would return the "timezone" option
|
||||||
|
* from the "application" configuration file.
|
||||||
|
*
|
||||||
|
* If the name of a configuration file is passed without specifying an item, the
|
||||||
|
* entire configuration array will be returned.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Get the timezone option from the application configuration file
|
||||||
|
* $timezone = Config::get('application.timezone');
|
||||||
|
*
|
||||||
|
* // Get the SQLite database connection configuration
|
||||||
|
* $sqlite = Config::get('db.connections.sqlite');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param string $default
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function get($key, $default = null)
|
||||||
|
{
|
||||||
|
list($module, $file, $key) = static::parse($key);
|
||||||
|
|
||||||
|
if ( ! static::load($module, $file))
|
||||||
|
{
|
||||||
|
return is_callable($default) ? call_user_func($default) : $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null($key)) return static::$items[$module][$file];
|
||||||
|
|
||||||
|
return Arr::get(static::$items[$module][$file], $key, $default);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a configuration item.
|
||||||
|
*
|
||||||
|
* Like the get method, "dot" notation is used to set items, and setting items
|
||||||
|
* at any depth in the configuration array is supported.
|
||||||
|
*
|
||||||
|
* If a specific configuration item is not specified, the entire configuration
|
||||||
|
* array will be replaced with the given value.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Set the timezone option in the application configuration file
|
||||||
|
* Config::set('application.timezone', 'America/Chicago');
|
||||||
|
*
|
||||||
|
* // Set the session configuration array
|
||||||
|
* Config::set('session', array());
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param mixed $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function set($key, $value)
|
||||||
|
{
|
||||||
|
list($module, $file, $key) = static::parse($key);
|
||||||
|
|
||||||
|
if ( ! static::load($module, $file))
|
||||||
|
{
|
||||||
|
throw new \Exception("Error setting configuration option. Configuration file [$file] is not defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Arr::set(static::$items[$module][$file], $key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a configuration key and return its module, file, and key segments.
|
||||||
|
*
|
||||||
|
* Modular configuration keys follow a {module}::{file}.{key} convention.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function parse($key)
|
||||||
|
{
|
||||||
|
list($module, $key) = Module::parse($key);
|
||||||
|
|
||||||
|
$segments = explode('.', $key);
|
||||||
|
|
||||||
|
return array($module, $segments[0], (count($segments) > 1) ? implode('.', array_slice($segments, 1)) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load all of the configuration items from a module configuration file.
|
||||||
|
*
|
||||||
|
* If the configuration file has already been loaded, it will not be loaded again.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @param string $module
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private static function load($module, $file)
|
||||||
|
{
|
||||||
|
if (isset(static::$items[$module]) and array_key_exists($file, static::$items[$module])) return true;
|
||||||
|
|
||||||
|
$config = array();
|
||||||
|
|
||||||
|
foreach (static::paths($module, $file) as $directory)
|
||||||
|
{
|
||||||
|
$config = (file_exists($path = $directory.$file.EXT)) ? array_merge($config, require $path) : $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($config) > 0) static::$items[$module][$file] = $config;
|
||||||
|
|
||||||
|
return isset(static::$items[$module][$file]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path hierarchy for a given configuration file and module.
|
||||||
|
*
|
||||||
|
* The paths returned by this method paths will be searched by the load method when merging
|
||||||
|
* configuration files, meaning the configuration files will cascade in this order.
|
||||||
|
*
|
||||||
|
* By default, the base configuration directory will be searched first, followed by the configuration
|
||||||
|
* directory for the active module. Next, any environment specific configuration directories
|
||||||
|
* will be searched.
|
||||||
|
*
|
||||||
|
* @param string $module
|
||||||
|
* @param string $file
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private static function paths($module, $file)
|
||||||
|
{
|
||||||
|
$paths = array(CONFIG_PATH, Module::path($module).'config/');
|
||||||
|
|
||||||
|
if (isset($_SERVER['LARAVEL_ENV']))
|
||||||
|
{
|
||||||
|
$paths[] = Module::path($module).'/config/'.$_SERVER['LARAVEL_ENV'].'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $paths;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Cookie {
|
class Cookie {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Crypter {
|
class Crypter {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class DB {
|
class DB {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\DB;
|
<?php namespace Laravel\DB;
|
||||||
|
|
||||||
class Connection {
|
class Connection {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace System\DB;
|
<?php namespace Laravel\DB;
|
||||||
|
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
|
|
||||||
class Connector {
|
class Connector {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php namespace System\DB;
|
<?php namespace Laravel\DB;
|
||||||
|
|
||||||
use System\Str;
|
use Laravel\Str;
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
use System\Paginator;
|
use Laravel\Paginator;
|
||||||
|
|
||||||
class Query {
|
class Query {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace System\Exception;
|
<?php namespace Laravel\Exception;
|
||||||
|
|
||||||
use System\File;
|
use Laravel\File;
|
||||||
|
|
||||||
class Examiner {
|
class Examiner {
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public function severity()
|
||||||
*/
|
*/
|
||||||
public function message()
|
public function message()
|
||||||
{
|
{
|
||||||
$file = str_replace(array(APP_PATH, SYS_PATH), array('APP_PATH/', 'SYS_PATH/'), $this->exception->getFile());
|
$file = str_replace(array(ACTIVE_MODULE_PATH, SYS_PATH), array('MODULE_PATH/', 'SYS_PATH/'), $this->exception->getFile());
|
||||||
|
|
||||||
return rtrim($this->exception->getMessage(), '.').' in '.$file.' on line '.$this->exception->getLine().'.';
|
return rtrim($this->exception->getMessage(), '.').' in '.$file.' on line '.$this->exception->getLine().'.';
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
<?php namespace System\Exception;
|
<?php namespace Laravel\Exception;
|
||||||
|
|
||||||
use System\View;
|
use Laravel\View;
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
use System\Response;
|
use Laravel\Response;
|
||||||
|
|
||||||
class Handler {
|
class Handler {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Form {
|
class Form {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Hash {
|
class Hash {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class HTML {
|
class HTML {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Inflector {
|
class Inflector {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Input {
|
class Input {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Lang {
|
class Lang {
|
||||||
|
|
||||||
|
@ -93,16 +93,11 @@ public function get($language = null, $default = null)
|
||||||
*/
|
*/
|
||||||
private function parse($key, $language)
|
private function parse($key, $language)
|
||||||
{
|
{
|
||||||
$module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : 'application';
|
list($module, $key) = Module::parse($key);
|
||||||
|
|
||||||
if ($module != 'application')
|
|
||||||
{
|
|
||||||
$key = substr($key, strpos($key, ':') + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($segments = explode('.', $key)) > 1)
|
if (count($segments = explode('.', $key)) > 1)
|
||||||
{
|
{
|
||||||
return array($module, $segments[0], $segments[1]);
|
return array($module, $segments[0], implode('.', array_slice($segments, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception("Invalid language line [$key]. A specific line must be specified.");
|
throw new \Exception("Invalid language line [$key]. A specific line must be specified.");
|
||||||
|
@ -120,9 +115,7 @@ private function load($module, $file, $language)
|
||||||
{
|
{
|
||||||
if (isset(static::$lines[$module][$language.$file])) return;
|
if (isset(static::$lines[$module][$language.$file])) return;
|
||||||
|
|
||||||
$path = ($module === 'application') ? LANG_PATH : MODULE_PATH.$module.'/lang/';
|
if (file_exists($path = Module::path($module).'lang/'.$language.'/'.$file.EXT))
|
||||||
|
|
||||||
if (file_exists($path = $path.$language.'/'.$file.EXT))
|
|
||||||
{
|
{
|
||||||
static::$lines[$module][$language.$file] = require $path;
|
static::$lines[$module][$language.$file] = require $path;
|
||||||
}
|
}
|
|
@ -1,51 +1,61 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Define the core framework paths.
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
define('APP_PATH', realpath($application).'/');
|
|
||||||
define('SYS_PATH', realpath($system).'/');
|
|
||||||
define('PUBLIC_PATH', realpath($public).'/');
|
|
||||||
define('PACKAGE_PATH', realpath($packages).'/');
|
|
||||||
define('MODULE_PATH', realpath($modules).'/');
|
|
||||||
define('STORAGE_PATH', realpath($storage).'/');
|
|
||||||
define('BASE_PATH', realpath(str_replace('system', '', $system)).'/');
|
|
||||||
|
|
||||||
unset($application, $system, $public, $packages, $modules, $storage);
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Define various other framework paths.
|
|
||||||
// --------------------------------------------------------------
|
|
||||||
define('CACHE_PATH', STORAGE_PATH.'cache/');
|
|
||||||
define('CONFIG_PATH', APP_PATH.'config/');
|
|
||||||
define('DATABASE_PATH', STORAGE_PATH.'db/');
|
|
||||||
define('LANG_PATH', APP_PATH.'lang/');
|
|
||||||
define('LIBRARY_PATH', APP_PATH.'libraries/');
|
|
||||||
define('MODEL_PATH', APP_PATH.'models/');
|
|
||||||
define('ROUTE_PATH', APP_PATH.'routes/');
|
|
||||||
define('SCRIPT_PATH', PUBLIC_PATH.'js/');
|
|
||||||
define('SESSION_PATH', STORAGE_PATH.'sessions/');
|
|
||||||
define('STYLE_PATH', PUBLIC_PATH.'css/');
|
|
||||||
define('VIEW_PATH', APP_PATH.'views/');
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Define the PHP file extension.
|
// Define the PHP file extension.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
define('EXT', '.php');
|
define('EXT', '.php');
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Define the core framework paths.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
define('BASE_PATH', realpath(str_replace('laravel', '', $system)).'/');
|
||||||
|
define('CONFIG_PATH', realpath($config).'/');
|
||||||
|
define('MODULE_PATH', realpath($modules).'/');
|
||||||
|
define('PACKAGE_PATH', realpath($packages).'/');
|
||||||
|
define('PUBLIC_PATH', realpath($public).'/');
|
||||||
|
define('STORAGE_PATH', realpath($storage).'/');
|
||||||
|
define('SYS_PATH', realpath($system).'/');
|
||||||
|
|
||||||
|
unset($system, $config, $modules, $packages, $public, $storage);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Define various other framework paths.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
define('CACHE_PATH', STORAGE_PATH.'cache/');
|
||||||
|
define('DATABASE_PATH', STORAGE_PATH.'db/');
|
||||||
|
define('SCRIPT_PATH', PUBLIC_PATH.'js/');
|
||||||
|
define('SESSION_PATH', STORAGE_PATH.'sessions/');
|
||||||
|
define('STYLE_PATH', PUBLIC_PATH.'css/');
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Define the default module.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
define('DEFAULT_MODULE', 'application');
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Load the classes used by the auto-loader.
|
// Load the classes used by the auto-loader.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
require SYS_PATH.'loader'.EXT;
|
require SYS_PATH.'loader'.EXT;
|
||||||
require SYS_PATH.'config'.EXT;
|
require SYS_PATH.'config'.EXT;
|
||||||
|
require SYS_PATH.'module'.EXT;
|
||||||
require SYS_PATH.'arr'.EXT;
|
require SYS_PATH.'arr'.EXT;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Register the active modules.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
Module::$modules = $active;
|
||||||
|
|
||||||
|
unset($active);
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Register the auto-loader.
|
// Register the auto-loader.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
Loader::bootstrap();
|
Loader::bootstrap(array(
|
||||||
|
Module::path(DEFAULT_MODULE).'libraries/',
|
||||||
|
Module::path(DEFAULT_MODULE).'models/',
|
||||||
|
));
|
||||||
|
|
||||||
spl_autoload_register(array('System\\Loader', 'load'));
|
spl_autoload_register(array('Laravel\\Loader', 'load'));
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Set the error reporting and display levels.
|
// Set the error reporting and display levels.
|
||||||
|
@ -55,33 +65,34 @@
|
||||||
ini_set('display_errors', 'Off');
|
ini_set('display_errors', 'Off');
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Register the error handlers.
|
// Register the error / exception handlers.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
set_exception_handler(function($e)
|
$error_dependencies = function()
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'exception/handler'.EXT;
|
require_once SYS_PATH.'exception/handler'.EXT;
|
||||||
require_once SYS_PATH.'exception/examiner'.EXT;
|
require_once SYS_PATH.'exception/examiner'.EXT;
|
||||||
require_once SYS_PATH.'file'.EXT;
|
require_once SYS_PATH.'file'.EXT;
|
||||||
|
};
|
||||||
|
|
||||||
|
set_exception_handler(function($e) use ($error_dependencies)
|
||||||
|
{
|
||||||
|
call_user_func($error_dependencies);
|
||||||
|
|
||||||
Exception\Handler::make($e)->handle();
|
Exception\Handler::make($e)->handle();
|
||||||
});
|
});
|
||||||
|
|
||||||
set_error_handler(function($number, $error, $file, $line)
|
set_error_handler(function($number, $error, $file, $line) use ($error_dependencies)
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'exception/handler'.EXT;
|
call_user_func($error_dependencies);
|
||||||
require_once SYS_PATH.'exception/examiner'.EXT;
|
|
||||||
require_once SYS_PATH.'file'.EXT;
|
|
||||||
|
|
||||||
Exception\Handler::make(new \ErrorException($error, $number, 0, $file, $line))->handle();
|
Exception\Handler::make(new \ErrorException($error, $number, 0, $file, $line))->handle();
|
||||||
});
|
});
|
||||||
|
|
||||||
register_shutdown_function(function()
|
register_shutdown_function(function() use ($error_dependencies)
|
||||||
{
|
{
|
||||||
if ( ! is_null($error = error_get_last()))
|
if ( ! is_null($error = error_get_last()))
|
||||||
{
|
{
|
||||||
require_once SYS_PATH.'exception/handler'.EXT;
|
call_user_func($error_dependencies);
|
||||||
require_once SYS_PATH.'exception/examiner'.EXT;
|
|
||||||
require_once SYS_PATH.'file'.EXT;
|
|
||||||
|
|
||||||
extract($error);
|
extract($error);
|
||||||
|
|
||||||
|
@ -97,10 +108,7 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Load the session.
|
// Load the session.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
if (Config::get('session.driver') != '')
|
if (Config::get('session.driver') != '') Session::load(Cookie::get('laravel_session'));
|
||||||
{
|
|
||||||
Session::load(Cookie::get('laravel_session'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Load all of the core routing classes.
|
// Load all of the core routing classes.
|
||||||
|
@ -127,21 +135,19 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
$segments = explode('/', Request::uri());
|
$segments = explode('/', Request::uri());
|
||||||
|
|
||||||
define('ACTIVE_MODULE', (in_array($segments[0], Config::get('application.modules'))) ? $segments[0] : 'application');
|
define('ACTIVE_MODULE', (array_key_exists($segments[0], Module::$modules)) ? $segments[0] : DEFAULT_MODULE);
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Determine the path to the root of the active module.
|
// Determine the path to the root of the active module.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
define('ACTIVE_MODULE_PATH', (ACTIVE_MODULE == 'application') ? APP_PATH : MODULE_PATH.ACTIVE_MODULE.'/');
|
define('ACTIVE_MODULE_PATH', Module::path(ACTIVE_MODULE));
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Register the filters for the active module.
|
// Register the filters for the active module.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
Routing\Filter::register(require APP_PATH.'filters'.EXT);
|
if (file_exists(ACTIVE_MODULE_PATH.'filters'.EXT))
|
||||||
|
|
||||||
if (ACTIVE_MODULE !== 'application' and file_exists($filters = ACTIVE_MODULE_PATH.'filters'.EXT))
|
|
||||||
{
|
{
|
||||||
Routing\Filter::register(require $filters);
|
Routing\Filter::register(require ACTIVE_MODULE_PATH.'filters'.EXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
@ -159,7 +165,9 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
if (is_null($response))
|
if (is_null($response))
|
||||||
{
|
{
|
||||||
$route = Routing\Router::make(Request::method(), Request::uri(), new Routing\Loader(ACTIVE_MODULE_PATH))->route();
|
$loader = new Routing\Loader(ACTIVE_MODULE_PATH);
|
||||||
|
|
||||||
|
$route = Routing\Router::make(Request::method(), Request::uri(), $loader)->route();
|
||||||
|
|
||||||
$response = (is_null($route)) ? Response::error('404') : $route->call();
|
$response = (is_null($route)) ? Response::error('404') : $route->call();
|
||||||
}
|
}
|
||||||
|
@ -182,10 +190,7 @@
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Close the session.
|
// Close the session.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
if (Config::get('session.driver') != '')
|
if (Config::get('session.driver') != '') Session::close();
|
||||||
{
|
|
||||||
Session::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// Send the response to the browser.
|
// Send the response to the browser.
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class Loader {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $paths = array(BASE_PATH, MODEL_PATH, LIBRARY_PATH);
|
public static $paths = array(BASE_PATH);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the class aliases.
|
* All of the class aliases.
|
||||||
|
@ -26,12 +26,14 @@ class Loader {
|
||||||
/**
|
/**
|
||||||
* Bootstrap the auto-loader.
|
* Bootstrap the auto-loader.
|
||||||
*
|
*
|
||||||
|
* @param array $paths
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function bootstrap()
|
public static function bootstrap($paths = array())
|
||||||
{
|
{
|
||||||
static::$aliases = Config::get('aliases');
|
static::$aliases = Config::get('aliases');
|
||||||
static::$modules = Config::get('application.modules');
|
|
||||||
|
foreach ($paths as $path) { static::register($path); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,7 +87,7 @@ private static function load_from_module($file)
|
||||||
// module name, we'll extract the module name from the file.
|
// module name, we'll extract the module name from the file.
|
||||||
$module = substr($file, 0, strpos($file, '/'));
|
$module = substr($file, 0, strpos($file, '/'));
|
||||||
|
|
||||||
if (in_array($module, static::$modules))
|
if (in_array($module, Module::$modules))
|
||||||
{
|
{
|
||||||
$module = MODULE_PATH.$module.'/';
|
$module = MODULE_PATH.$module.'/';
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Memcached {
|
class Memcached {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Messages {
|
class Messages {
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?php namespace Laravel;
|
||||||
|
|
||||||
|
class Module {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The active modules for the installation.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public static $modules = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All of the loaded module paths.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $paths = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a modularized identifier and get the module and key.
|
||||||
|
*
|
||||||
|
* Modular identifiers follow a {module}::{key} convention.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function parse($key)
|
||||||
|
{
|
||||||
|
$module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : DEFAULT_MODULE;
|
||||||
|
|
||||||
|
if ($module !== DEFAULT_MODULE) $key = substr($key, strpos($key, ':') + 2);
|
||||||
|
|
||||||
|
return array($module, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the path for a given module.
|
||||||
|
*
|
||||||
|
* @param string $module
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function path($module)
|
||||||
|
{
|
||||||
|
if (array_key_exists($module, static::$paths)) return static::$paths[$module];
|
||||||
|
|
||||||
|
if (array_key_exists($module, static::$modules))
|
||||||
|
{
|
||||||
|
$path = (strpos(static::$modules[$module], BASE_PATH) === 0) ? static::$modules[$module].'/' : MODULE_PATH.static::$modules[$module].'/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return static::$paths[$module] = $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the an array of paths to all of the modules.
|
||||||
|
*
|
||||||
|
* The module paths will be determined by the modules that are specified in the application
|
||||||
|
* modules configuration item. A trailing slash will be added to the paths.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function paths()
|
||||||
|
{
|
||||||
|
return array_map(function($module) { return Laravel\Module::path($module); }, static::$modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Package {
|
class Package {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Paginator {
|
class Paginator {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Redirect {
|
class Redirect {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Request {
|
class Request {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Response {
|
class Response {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
class Filter {
|
class Filter {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
class Finder {
|
class Finder {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace System\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ private function load_nested_routes($segments)
|
||||||
|
|
||||||
// Since it is no part of the route directory structure, shift the module name off of the
|
// Since it is no part of the route directory structure, shift the module name off of the
|
||||||
// beginning of the array so we can locate the appropriate route file.
|
// beginning of the array so we can locate the appropriate route file.
|
||||||
if (count($segments) > 0 and ACTIVE_MODULE !== 'application')
|
if (count($segments) > 0 and ACTIVE_MODULE !== DEFAULT_MODULE)
|
||||||
{
|
{
|
||||||
array_shift($segments);
|
array_shift($segments);
|
||||||
}
|
}
|
||||||
|
@ -87,21 +87,15 @@ private function load_nested_routes($segments)
|
||||||
* will be cached and returned on every subsequent call.
|
* will be cached and returned on every subsequent call.
|
||||||
*
|
*
|
||||||
* @param bool $reload
|
* @param bool $reload
|
||||||
* @param string $path
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function all($reload = false, $path = APP_PATH)
|
public static function all($reload = false)
|
||||||
{
|
{
|
||||||
if ( ! is_null(static::$routes) and ! $reload) return static::$routes;
|
if ( ! is_null(static::$routes) and ! $reload) return static::$routes;
|
||||||
|
|
||||||
// Merge all of the module paths in with the specified path so that all
|
|
||||||
// active module routes will also be loaded. So, by default, this method
|
|
||||||
// will search the application path and all active module paths for routes.
|
|
||||||
$paths = array_merge(array($path), array_map(function($module) { return MODULE_PATH.$module.'/'; }, Config::get('application.modules')));
|
|
||||||
|
|
||||||
$routes = array();
|
$routes = array();
|
||||||
|
|
||||||
foreach ($paths as $path)
|
foreach (Module::paths() as $path)
|
||||||
{
|
{
|
||||||
if (file_exists($path.'routes'.EXT))
|
if (file_exists($path.'routes'.EXT))
|
||||||
{
|
{
|
|
@ -1,7 +1,7 @@
|
||||||
<?php namespace System\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
use System\Package;
|
use Laravel\Package;
|
||||||
use System\Response;
|
use Laravel\Response;
|
||||||
|
|
||||||
class Route {
|
class Route {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace System\Routing;
|
<?php namespace Laravel\Routing;
|
||||||
|
|
||||||
use System\Request;
|
use Laravel\Request;
|
||||||
|
|
||||||
class Router {
|
class Router {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Session {
|
class Session {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
use System\Cache;
|
use Laravel\Cache;
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
|
|
||||||
class APC implements Driver {
|
class APC implements Driver {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
use System\Crypter;
|
use Laravel\Crypter;
|
||||||
|
|
||||||
class Cookie implements Driver {
|
class Cookie implements Driver {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
|
|
||||||
class DB implements Driver, Sweeper {
|
class DB implements Driver, Sweeper {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
interface Driver {
|
interface Driver {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
class File implements Driver, Sweeper {
|
class File implements Driver, Sweeper {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
use System\Cache;
|
use Laravel\Cache;
|
||||||
use System\Config;
|
use Laravel\Config;
|
||||||
|
|
||||||
class Memcached implements Driver {
|
class Memcached implements Driver {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System\Session;
|
<?php namespace Laravel\Session;
|
||||||
|
|
||||||
interface Sweeper {
|
interface Sweeper {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Str {
|
class Str {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class URL {
|
class URL {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?php namespace System;
|
<?php namespace Laravel;
|
||||||
|
|
||||||
class Validator {
|
class Validator {
|
||||||
|
|
|
@ -68,9 +68,8 @@ public static function make($view, $data = array())
|
||||||
/**
|
/**
|
||||||
* Create a new view instance from a view name.
|
* Create a new view instance from a view name.
|
||||||
*
|
*
|
||||||
* The view names for the active module will be searched first, followed by
|
* The view names for the active module will be searched first, followed by the view names
|
||||||
* the view names for the application directory, followed by the view names
|
* for the default module. Finally, the names for all modules will be searched.
|
||||||
* for all other modules.
|
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
@ -78,7 +77,7 @@ public static function make($view, $data = array())
|
||||||
*/
|
*/
|
||||||
protected static function of($name, $data = array())
|
protected static function of($name, $data = array())
|
||||||
{
|
{
|
||||||
foreach (array_unique(array_merge(array(ACTIVE_MODULE, 'application'), Config::get('application.modules'))) as $module)
|
foreach (array_unique(array_merge(array(ACTIVE_MODULE, DEFAULT_MODULE), Module::$modules)) as $module)
|
||||||
{
|
{
|
||||||
static::load_composers($module);
|
static::load_composers($module);
|
||||||
|
|
||||||
|
@ -102,16 +101,9 @@ protected static function of($name, $data = array())
|
||||||
*/
|
*/
|
||||||
protected static function parse($view)
|
protected static function parse($view)
|
||||||
{
|
{
|
||||||
$module = (strpos($view, '::') !== false) ? substr($view, 0, strpos($view, ':')) : 'application';
|
list($module, $view) = Module::parse($view);
|
||||||
|
|
||||||
$path = ($module == 'application') ? VIEW_PATH : MODULE_PATH.$module.'/views/';
|
return array($module, Module::path($module).'views/', $view);
|
||||||
|
|
||||||
if ($module != 'application')
|
|
||||||
{
|
|
||||||
$view = substr($view, strpos($view, ':') + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($module, $path, $view);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +134,7 @@ protected static function load_composers($module)
|
||||||
{
|
{
|
||||||
if (isset(static::$composers[$module])) return;
|
if (isset(static::$composers[$module])) return;
|
||||||
|
|
||||||
$composers = ($module == 'application') ? APP_PATH.'composers'.EXT : MODULE_PATH.$module.'/composers'.EXT;
|
$composers = Module::path($module).'composers'.EXT;
|
||||||
|
|
||||||
static::$composers[$module] = (file_exists($composers)) ? require $composers : array();
|
static::$composers[$module] = (file_exists($composers)) ? require $composers : array();
|
||||||
}
|
}
|
Binary file not shown.
|
@ -3,20 +3,27 @@
|
||||||
* Laravel - A clean and classy framework for PHP web development.
|
* Laravel - A clean and classy framework for PHP web development.
|
||||||
*
|
*
|
||||||
* @package Laravel
|
* @package Laravel
|
||||||
* @version 1.5.3
|
* @version 2.0.0
|
||||||
* @author Taylor Otwell
|
* @author Taylor Otwell
|
||||||
* @link http://laravel.com
|
* @link http://laravel.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// The path to the application directory.
|
// The active modules for this Laravel installation.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
$application = '../application';
|
$active = array(
|
||||||
|
'application' => realpath('../application'),
|
||||||
|
);
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// The path to the system directory.
|
// The path to the Laravel directory.
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
$system = '../system';
|
$system = '../laravel';
|
||||||
|
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// The path to the configuration directory.
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
$config = '../config';
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// The path to the packages directory.
|
// The path to the packages directory.
|
||||||
|
|
|
@ -1,96 +0,0 @@
|
||||||
<?php namespace System;
|
|
||||||
|
|
||||||
class Cache {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All of the active cache drivers.
|
|
||||||
*
|
|
||||||
* @var Cache\Driver
|
|
||||||
*/
|
|
||||||
public static $drivers = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a cache driver instance.
|
|
||||||
*
|
|
||||||
* If no driver name is specified, the default cache driver will be returned
|
|
||||||
* as defined in the cache configuration file.
|
|
||||||
*
|
|
||||||
* @param string $driver
|
|
||||||
* @return Cache\Driver
|
|
||||||
*/
|
|
||||||
public static function driver($driver = null)
|
|
||||||
{
|
|
||||||
if (is_null($driver)) $driver = Config::get('cache.driver');
|
|
||||||
|
|
||||||
if ( ! array_key_exists($driver, static::$drivers))
|
|
||||||
{
|
|
||||||
switch ($driver)
|
|
||||||
{
|
|
||||||
case 'file':
|
|
||||||
return static::$drivers[$driver] = new Cache\File;
|
|
||||||
|
|
||||||
case 'memcached':
|
|
||||||
return static::$drivers[$driver] = new Cache\Memcached;
|
|
||||||
|
|
||||||
case 'apc':
|
|
||||||
return static::$drivers[$driver] = new Cache\APC;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new \Exception("Cache driver [$driver] is not supported.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return static::$drivers[$driver];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $default
|
|
||||||
* @param string $driver
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function get($key, $default = null, $driver = null)
|
|
||||||
{
|
|
||||||
if (is_null($item = static::driver($driver)->get($key)))
|
|
||||||
{
|
|
||||||
return is_callable($default) ? call_user_func($default) : $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache. If the item doesn't exist in the cache, store
|
|
||||||
* the default value in the cache and return it.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $default
|
|
||||||
* @param int $minutes
|
|
||||||
* @param string $driver
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public static function remember($key, $default, $minutes, $driver = null)
|
|
||||||
{
|
|
||||||
if ( ! is_null($item = static::get($key, null, $driver))) return $item;
|
|
||||||
|
|
||||||
$default = is_callable($default) ? call_user_func($default) : $default;
|
|
||||||
|
|
||||||
static::driver($driver)->put($key, $default, $minutes);
|
|
||||||
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pass all other methods to the default driver.
|
|
||||||
*
|
|
||||||
* Passing method calls to the driver instance provides a better API for you.
|
|
||||||
* For instance, instead of saying Cache::driver()->foo(), you can just say Cache::foo().
|
|
||||||
*/
|
|
||||||
public static function __callStatic($method, $parameters)
|
|
||||||
{
|
|
||||||
return call_user_func_array(array(static::driver(), $method), $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
<?php namespace System\Cache;
|
|
||||||
|
|
||||||
use System\Config;
|
|
||||||
|
|
||||||
class APC implements Driver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if an item exists in the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function has($key)
|
|
||||||
{
|
|
||||||
return ( ! is_null($this->get($key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get($key)
|
|
||||||
{
|
|
||||||
return ( ! is_null($cache = apc_fetch(Config::get('cache.key').$key))) ? $cache : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write an item to the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $minutes
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function put($key, $value, $minutes)
|
|
||||||
{
|
|
||||||
apc_store(Config::get('cache.key').$key, $value, $minutes * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function forget($key)
|
|
||||||
{
|
|
||||||
apc_delete(Config::get('cache.key').$key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php namespace System\Cache;
|
|
||||||
|
|
||||||
interface Driver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if an item exists in the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function has($key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get($key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write an item to the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $minutes
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function put($key, $value, $minutes);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function forget($key);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php namespace System\Cache;
|
|
||||||
|
|
||||||
class File implements Driver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if an item exists in the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function has($key)
|
|
||||||
{
|
|
||||||
return ( ! is_null($this->get($key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $default
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get($key)
|
|
||||||
{
|
|
||||||
if ( ! file_exists(CACHE_PATH.$key))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cache = file_get_contents(CACHE_PATH.$key);
|
|
||||||
|
|
||||||
// The cache expiration date is stored as a UNIX timestamp at the beginning
|
|
||||||
// of the cache file. We'll extract it out and check it here.
|
|
||||||
if (time() >= substr($cache, 0, 10)) return $this->forget($key);
|
|
||||||
|
|
||||||
return unserialize(substr($cache, 10));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write an item to the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $minutes
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function put($key, $value, $minutes)
|
|
||||||
{
|
|
||||||
file_put_contents(CACHE_PATH.$key, (time() + ($minutes * 60)).serialize($value), LOCK_EX);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function forget($key)
|
|
||||||
{
|
|
||||||
@unlink(CACHE_PATH.$key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
<?php namespace System\Cache;
|
|
||||||
|
|
||||||
use System\Config;
|
|
||||||
|
|
||||||
class Memcached implements Driver {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if an item exists in the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function has($key)
|
|
||||||
{
|
|
||||||
return ( ! is_null($this->get($key)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function get($key)
|
|
||||||
{
|
|
||||||
return (($cache = \System\Memcached::instance()->get(Config::get('cache.key').$key)) !== false) ? $cache : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write an item to the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
* @param int $minutes
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function put($key, $value, $minutes)
|
|
||||||
{
|
|
||||||
\System\Memcached::instance()->set(Config::get('cache.key').$key, $value, 0, $minutes * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete an item from the cache.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function forget($key)
|
|
||||||
{
|
|
||||||
\System\Memcached::instance()->delete(Config::get('cache.key').$key);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
<?php namespace System;
|
|
||||||
|
|
||||||
class Config {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All of the loaded configuration items.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $items = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a configuration item or file exists.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function has($key)
|
|
||||||
{
|
|
||||||
return ! is_null(static::get($key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a configuration item.
|
|
||||||
*
|
|
||||||
* Configuration items are retrieved using "dot" notation. So, asking for the
|
|
||||||
* "application.timezone" configuration item would return the "timezone" option
|
|
||||||
* from the "application" configuration file.
|
|
||||||
*
|
|
||||||
* If the name of a configuration file is passed without specifying an item, the
|
|
||||||
* entire configuration array will be returned.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param string $default
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function get($key, $default = null)
|
|
||||||
{
|
|
||||||
list($module, $file, $key) = static::parse($key);
|
|
||||||
|
|
||||||
if ( ! static::load($module, $file))
|
|
||||||
{
|
|
||||||
return is_callable($default) ? call_user_func($default) : $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_null($key)) return static::$items[$module][$file];
|
|
||||||
|
|
||||||
return Arr::get(static::$items[$module][$file], $key, $default);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a configuration item.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @param mixed $value
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function set($key, $value)
|
|
||||||
{
|
|
||||||
list($module, $file, $key) = static::parse($key);
|
|
||||||
|
|
||||||
if ( ! static::load($module, $file))
|
|
||||||
{
|
|
||||||
throw new \Exception("Error setting configuration option. Configuration file [$file] is not defined.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Arr::set(static::$items[$module][$file], $key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a configuration key.
|
|
||||||
*
|
|
||||||
* The value on the left side of the dot is the configuration file
|
|
||||||
* name, while the right side of the dot is the item within that file.
|
|
||||||
*
|
|
||||||
* @param string $key
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function parse($key)
|
|
||||||
{
|
|
||||||
$module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : 'application';
|
|
||||||
|
|
||||||
if ($module !== 'application')
|
|
||||||
{
|
|
||||||
$key = substr($key, strpos($key, ':') + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = (count($segments = explode('.', $key)) > 1) ? implode('.', array_slice($segments, 1)) : null;
|
|
||||||
|
|
||||||
return array($module, $segments[0], $key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load all of the configuration items from a file.
|
|
||||||
*
|
|
||||||
* Laravel supports environment specific configuration files. So, the base configuration
|
|
||||||
* array will be loaded first, then any environment specific options will be merged in.
|
|
||||||
*
|
|
||||||
* @param string $file
|
|
||||||
* @param string $module
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private static function load($module, $file)
|
|
||||||
{
|
|
||||||
if (isset(static::$items[$module]) and array_key_exists($file, static::$items[$module])) return true;
|
|
||||||
|
|
||||||
$path = ($module === 'application') ? CONFIG_PATH : MODULE_PATH.$module.'/config/';
|
|
||||||
|
|
||||||
// Load the base configuration file. Once that is loaded, we will merge any environment
|
|
||||||
// specific configuration options into the base array. This allows for the convenient
|
|
||||||
// cascading of configuration options depending on the application environment.
|
|
||||||
$config = (file_exists($base = $path.$file.EXT)) ? require $base : array();
|
|
||||||
|
|
||||||
if (isset($_SERVER['LARAVEL_ENV']) and file_exists($path = $path.$_SERVER['LARAVEL_ENV'].'/'.$file.EXT))
|
|
||||||
{
|
|
||||||
$config = array_merge($config, require $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($config) > 0) static::$items[$module][$file] = $config;
|
|
||||||
|
|
||||||
return isset(static::$items[$module][$file]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue