Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged skunkworks into develop.

  • Loading branch information...
commit b5442c67fc1e46a27939fcc5c78f8a2be57f74df 1 parent 610d882
@taylorotwell taylorotwell authored
Showing with 7,223 additions and 3,954 deletions.
  1. +42 −0 application/bundle.php
  2. +0 −47 application/composers.php
  3. +38 −16 application/config/application.php
  4. +18 −36 application/config/auth.php
  5. +29 −12 application/config/cache.php
  6. +0 −54 application/config/container.php
  7. +22 −26 application/config/database.php
  8. +7 −11 application/config/error.php
  9. 0  {laravel → application}/config/mimes.php
  10. +11 −10 application/config/session.php
  11. +119 −0 application/config/strings.php
  12. +3 −3 application/controllers/home.php
  13. +0 −68 application/filters.php
  14. +2 −2 application/language/en/pagination.php
  15. +8 −7 application/language/en/validation.php
  16. 0  application/migrations/.gitignore
  17. +82 −37 application/routes.php
  18. +0 −1  application/storage/cache/.gitignore
  19. +0 −1  application/storage/sessions/.gitignore
  20. +0 −1  application/storage/views/.gitignore
  21. 0  application/tasks/.gitignore
  22. +49 −0 artisan
  23. 0  bundles/.gitignore
  24. +0 −25 changelog.md
  25. +0 −166 laravel/arr.php
  26. +55 −12 laravel/asset.php
  27. +53 −48 laravel/auth.php
  28. +76 −109 laravel/autoloader.php
  29. +0 −49 laravel/benchmark.php
  30. +1 −9 laravel/blade.php
  31. +294 −0 laravel/bundle.php
  32. +17 −22 laravel/{cache/manager.php → cache.php}
  33. +113 −0 laravel/cache/drivers/database.php
  34. +14 −8 laravel/cache/drivers/driver.php
  35. +2 −5 laravel/cache/drivers/file.php
  36. +62 −0 laravel/cli/artisan.php
  37. +109 −0 laravel/cli/command.php
  38. +127 −0 laravel/cli/tasks/bundle/bundler.php
  39. +27 −0 laravel/cli/tasks/bundle/providers/github.php
  40. +13 −0 laravel/cli/tasks/bundle/providers/provider.php
  41. +90 −0 laravel/cli/tasks/bundle/publisher.php
  42. +29 −0 laravel/cli/tasks/bundle/repository.php
  43. +83 −0 laravel/cli/tasks/migrate/database.php
  44. +235 −0 laravel/cli/tasks/migrate/migrator.php
  45. +159 −0 laravel/cli/tasks/migrate/resolver.php
  46. +25 −0 laravel/cli/tasks/migrate/stub.php
  47. +3 −0  laravel/cli/tasks/task.php
  48. +75 −41 laravel/config.php
  49. +0 −73 laravel/config/ascii.php
  50. +67 −59 laravel/cookie.php
  51. +50 −67 laravel/core.php
  52. +18 −26 laravel/crypter.php
  53. +20 −25 laravel/{database/manager.php → database.php}
  54. +112 −79 laravel/database/connection.php
  55. +2 −2 laravel/database/connectors/connector.php
  56. +2 −2 laravel/database/connectors/mysql.php
  57. +2 −2 laravel/database/connectors/postgres.php
  58. +4 −30 laravel/database/connectors/sqlite.php
  59. +38 −0 laravel/database/connectors/sqlserver.php
  60. +0 −212 laravel/database/eloquent/hydrator.php
  61. +0 −538 laravel/database/eloquent/model.php
  62. +108 −0 laravel/database/grammar.php
  63. +196 −42 laravel/database/query.php
  64. +115 −160 laravel/database/{ → query}/grammars/grammar.php
  65. +2 −2 laravel/database/{ → query}/grammars/mysql.php
  66. +139 −0 laravel/database/query/grammars/sqlserver.php
  67. +119 −0 laravel/database/schema.php
  68. +38 −0 laravel/database/schema/grammars/grammar.php
  69. +386 −0 laravel/database/schema/grammars/mysql.php
  70. +381 −0 laravel/database/schema/grammars/postgres.php
  71. +344 −0 laravel/database/schema/grammars/sqlite.php
  72. +402 −0 laravel/database/schema/grammars/sqlserver.php
  73. +371 −0 laravel/database/schema/table.php
  74. +96 −0 laravel/error.php
  75. +73 −0 laravel/event.php
  76. +0 −66 laravel/facades.php
  77. +2 −26 laravel/file.php
  78. +80 −0 laravel/fluent.php
  79. +12 −23 laravel/form.php
  80. +10 −11 laravel/hash.php
  81. +283 −0 laravel/helpers.php
  82. +12 −49 laravel/html.php
  83. +0 −205 laravel/inflector.php
  84. +69 −47 laravel/input.php
  85. +18 −49 laravel/ioc.php
  86. +63 −54 laravel/lang.php
  87. +56 −82 laravel/laravel.php
  88. +65 −0 laravel/log.php
  89. +14 −18 laravel/memcached.php
  90. +9 −11 laravel/messages.php
  91. +11 −6 laravel/paginator.php
  92. +46 −52 laravel/redirect.php
  93. +4 −4 laravel/redis.php
  94. +14 −15 laravel/request.php
  95. +61 −74 laravel/response.php
  96. +116 −77 laravel/routing/controller.php
  97. +156 −80 laravel/routing/filter.php
  98. +0 −120 laravel/routing/loader.php
  99. +104 −121 laravel/routing/route.php
  100. +153 −118 laravel/routing/router.php
  101. +4 −14 laravel/section.php
  102. +117 −0 laravel/session.php
  103. +1 −1  laravel/session/drivers/database.php
  104. +0 −40 laravel/session/drivers/factory.php
  105. +70 −65 laravel/session/payload.php
  106. +146 −52 laravel/str.php
  107. +14 −16 laravel/uri.php
  108. +66 −132 laravel/url.php
  109. +107 −49 laravel/validator.php
  110. +143 −127 laravel/view.php
  111. 0  public/bundles/.gitignore
  112. +20 −5 public/index.php
  113. 0  storage/cache/.gitignore
  114. 0  {application → }/storage/database/.gitignore
  115. 0  storage/logs/.gitignore
  116. 0  storage/sessions/.gitignore
  117. 0  storage/views/.gitignore
View
42 application/bundle.php
@@ -0,0 +1,42 @@
+<?php
+
+/*
+|--------------------------------------------------------------------------
+| Auto-Loader PSR-0 Directories
+|--------------------------------------------------------------------------
+|
+| The Laravel auto-loader can search directories for files using the PSR-0
+| naming convention. This convention basically organizes classes by using
+| the class namespace to indicate the directory structure.
+|
+| So you don't have to manually map all of your models, we've added the
+| models and libraries directories for you. So, you can model away and
+| the auto-loader will take care of the rest.
+|
+*/
+
+Autoloader::psr(array(
+ APP_PATH.'models',
+ APP_PATH.'libraries',
+));
+
+/*
+|--------------------------------------------------------------------------
+| Auto-Loader Mappings
+|--------------------------------------------------------------------------
+|
+| Laravel uses a simple array of class to path mappings to drive the class
+| auto-loader. This simple approach helps avoid the performance problems
+| of searching through directories by some kind of convention. It also
+| gives you the freedom to organize your application how you want.
+|
+| Registering a mapping couldn't be easier. Just pass an array of class
+| to path maps into the "map" function of Autoloader. Then, when you
+| want to use that class, just use it. It's a piece of cake.
+|
+*/
+
+Autoloader::map(array(
+ //'User' => APP_PATH.'models/user.php',
+ //'Role' => APP_PATH.'models/role.php',
+));
View
47 application/composers.php
@@ -1,47 +0,0 @@
-<?php
-
-return array(
-
- /*
- |--------------------------------------------------------------------------
- | View Names & Composers
- |--------------------------------------------------------------------------
- |
- | Named views give you beautiful syntax when working with your views.
- |
- | Here's how to define a named view:
- |
- | 'home.index' => array('name' => 'home')
- |
- | Now, you can create an instance of that view using the very expressive
- | View::of dynamic method. Take a look at this example:
- |
- | return View::of_home();
- |
- | View composers provide a convenient way to add common elements to a view
- | each time it is created. For example, you may wish to bind a header and
- | footer partial each time the view is created.
- |
- | The composer will receive an instance of the view being created, and is
- | free to modify the view however you wish. Here is how to define one:
- |
- | 'home.index' => function($view)
- | {
- | //
- | }
- |
- | Of course, you may define a view name and a composer for a single view:
- |
- | 'home.index' => array('name' => 'home', function($view)
- | {
- | //
- | })
- |
- */
-
- 'home.index' => array('name' => 'home', function($view)
- {
- // This composer is called for the "home.index" view.
- }),
-
-);
View
54 application/config/application.php
@@ -7,7 +7,9 @@
| Application URL
|--------------------------------------------------------------------------
|
- | The URL used to access your application. No trailing slash.
+ | The URL used to access your application without a trailing slash. The URL
+ | does nto have to be set. If it isn't we'll try our best to guess the URL
+ | of your application.
|
*/
@@ -20,8 +22,8 @@
|
| If you are including the "index.php" in your URLs, you can ignore this.
|
- | However, if you are using mod_rewrite or something similar to get
- | cleaner URLs, set this option to an empty string.
+ | However, if you are using mod_rewrite to get cleaner URLs, just set
+ | this option to an empty string and we'll take care of the rest.
|
*/
@@ -32,11 +34,10 @@
| Application Key
|--------------------------------------------------------------------------
|
- | The application key should be a random, 32 character string.
- |
| This key is used by the encryption and cookie classes to generate secure
| encrypted strings and hashes. It is extremely important that this key
- | remain secret and should not be shared with anyone.
+ | remain secret and should not be shared with anyone. Make it about 32
+ | characters of random gibberish.
|
*/
@@ -48,7 +49,8 @@
|--------------------------------------------------------------------------
|
| The default character encoding used by your application. This encoding
- | will be used by the Str, Text, and Form classes.
+ | will be used by the Str, Text, Form, and any other classes that need
+ | to know what type of encoding to use for your awesome application.
|
*/
@@ -89,7 +91,8 @@
|--------------------------------------------------------------------------
|
| The default timezone of your application. This timezone will be used when
- | Laravel needs a date, such as when writing to a log file.
+ | Laravel needs a date, such as when writing to a log file or travelling
+ | to a distant star at warp speed.
|
*/
@@ -97,6 +100,21 @@
/*
|--------------------------------------------------------------------------
+ | Autoloaded Bundles
+ |--------------------------------------------------------------------------
+ |
+ | Bundles can provide a ton of awesome drop-in functionality for your web
+ | application. Everything from Twitter integration to an admin backend.
+ |
+ | Here you may specify the bundles that should be automatically started
+ | on every request to your application.
+ |
+ */
+
+ 'bundles' => array(),
+
+ /*
+ |--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
@@ -112,26 +130,26 @@
*/
'aliases' => array(
- 'Arr' => 'Laravel\\Arr',
- 'Asset' => 'Laravel\\Asset',
'Auth' => 'Laravel\\Auth',
+ 'Asset' => 'Laravel\\Asset',
'Autoloader' => 'Laravel\\Autoloader',
- 'Benchmark' => 'Laravel\\Benchmark',
- 'Cache' => 'Laravel\\Cache\\Manager',
+ 'Bundle' => 'Laravel\\Bundle',
+ 'Cache' => 'Laravel\\Cache',
'Config' => 'Laravel\\Config',
'Controller' => 'Laravel\\Routing\\Controller',
'Cookie' => 'Laravel\\Cookie',
'Crypter' => 'Laravel\\Crypter',
- 'DB' => 'Laravel\\Database\\Manager',
- 'Eloquent' => 'Laravel\\Database\\Eloquent\\Model',
+ 'DB' => 'Laravel\\Database',
+ 'Event' => 'Laravel\\Event',
'File' => 'Laravel\\File',
+ 'Filter' => 'Laravel\\Routing\\Filter',
'Form' => 'Laravel\\Form',
'Hash' => 'Laravel\\Hash',
'HTML' => 'Laravel\\HTML',
- 'Inflector' => 'Laravel\\Inflector',
'Input' => 'Laravel\\Input',
'IoC' => 'Laravel\\IoC',
'Lang' => 'Laravel\\Lang',
+ 'Log' => 'Laravel\\Log',
'Memcached' => 'Laravel\\Memcached',
'Paginator' => 'Laravel\\Paginator',
'URL' => 'Laravel\\URL',
@@ -139,9 +157,13 @@
'Redis' => 'Laravel\\Redis',
'Request' => 'Laravel\\Request',
'Response' => 'Laravel\\Response',
+ 'Router' => 'Laravel\\Routing\\Router',
+ 'Schema' => 'Laravel\\Database\\Schema',
'Section' => 'Laravel\\Section',
- 'Session' => 'Laravel\\Facades\\Session',
+ 'Session' => 'Laravel\\Session',
'Str' => 'Laravel\\Str',
+ 'Task' => 'Laravel\\CLI\\Tasks\\Task',
+ 'URI' => 'Laravel\\URI',
'Validator' => 'Laravel\\Validator',
'View' => 'Laravel\\View',
),
View
54 application/config/auth.php
@@ -4,43 +4,25 @@
/*
|--------------------------------------------------------------------------
- | Authentication Username
- |--------------------------------------------------------------------------
- |
- } This option should be set to the "username" property of your users.
- | Typically, this will be set to "email" or "username".
- |
- | The value of this property will be used by the "attempt" closure when
- | searching for users by their username. It will also be used when the
- | user is set to be "remembered", as the username is embedded into the
- | encrypted cookie and is used to verify the user's identity.
- |
- */
-
- 'username' => 'email',
-
- /*
- |--------------------------------------------------------------------------
| Retrieve The Current User
|--------------------------------------------------------------------------
|
- | This closure is called by the Auth::user() method when attempting to
- | retrieve a user by their ID stored in the session.
+ | This closure is called by the Auth class' "user" method when trying to
+ | retrieve a user by the ID that is stored in their session. If you find
+ | the user, just return the user object, but make sure it has an "id"
+ | property. If you can't find the user, just return null.
|
- | Simply return an object representing the user with the given ID. Or, if
- | no user with the given ID is registered to use your application, you do
- | not need to return anything.
- |
- | Of course, a simple, elegant authentication solution is already provided
- | for you using Eloquent and the default Laravel hashing engine.
+ | Of course, a simple and elegant authentication solution has already
+ | been provided for you using the query builder and hashing engine.
+ | We love making your life as easy as possible.
|
*/
'user' => function($id)
{
- if ( ! is_null($id) and filter_var($id, FILTER_VALIDATE_INT) !== false)
+ if (filter_var($id, FILTER_VALIDATE_INT) !== false)
{
- return User::find($id);
+ return DB::table('users')->find($id);
}
},
@@ -50,19 +32,19 @@
|--------------------------------------------------------------------------
|
| This closure is called by the Auth::attempt() method when attempting to
- | authenticate a user that is logging into your application.
+ | authenticate a user that is logging into your application. It's like a
+ | super buff bouncer to your application.
|
| If the provided credentials are correct, simply return an object that
- | represents the user being authenticated. If the credentials are not
- | valid, don't return anything.
- |
- | Note: If a user object is returned, it must have an "id" property.
+ | represents the user being authenticated. As long as it has a property
+ | for the "id", any object will work. If the credentials are not valid,
+ | you don't meed to return anything.
|
*/
- 'attempt' => function($username, $password, $config)
+ 'attempt' => function($username, $password)
{
- $user = User::where($config['username'], '=', $username)->first();
+ $user = DB::table('users')->where_username($username)->first();
if ( ! is_null($user) and Hash::check($password, $user->password))
{
@@ -72,12 +54,12 @@
/*
|--------------------------------------------------------------------------
- | Logout
+ | Logout The Current User
|--------------------------------------------------------------------------
|
| Here you may do anything that needs to be done when a user logs out of
| your application, such as call the logout method on a third-party API
- | you are using for authentication, or anything else you desire.
+ | you are using for authentication or anything else you desire.
|
*/
View
41 application/config/cache.php
@@ -7,12 +7,15 @@
| Cache Driver
|--------------------------------------------------------------------------
|
- | The name of the default cache driver for your application.
+ | The name of the default cache driver for your application. Caching can
+ | be used to increase the performance of your application by storing any
+ | commonly accessed data in memory, a file, or some other storage.
|
- | Caching can be used to increase the performance of your application
- | by storing commonly accessed data in memory or in a file.
+ | A variety of awesome drivers are available for you to use with Laravel.
+ | Some, like APC, are extremely fast. However, if that isn't an option
+ | in your environment, try file or database caching.
|
- | Supported Drivers: 'file', 'memcached', 'apc', 'redis'.
+ | Drivers: 'file', 'memcached', 'apc', 'redis', 'database'.
|
*/
@@ -23,8 +26,10 @@
| Cache Key
|--------------------------------------------------------------------------
|
- | This key will be prepended to item keys stored using Memcached and APC to
- | prevent collisions with other applications on the server.
+ | This key will be prepended to item keys stored using Memcached and APC
+ | to prevent collisions with other applications on the server. Since the
+ | memory based stores could be shared by other applications, we need to
+ | be polite and use a prefix to uniquely identifier our items.
|
*/
@@ -32,16 +37,28 @@
/*
|--------------------------------------------------------------------------
- | Memcached Servers
+ | Cache Database
|--------------------------------------------------------------------------
|
- | The Memcached servers used by your application.
+ | When using the database cache driver, this database table will be used
+ | to store the cached item. You may also add a "connection" option to
+ | the array to specify which database connection should be used.
+ |
+ */
+
+ 'database' => array('table' => 'laravel_cache'),
+
+ /*
+ |--------------------------------------------------------------------------
+ | Memcached Servers
+ |--------------------------------------------------------------------------
|
- | Memcached is a free and open source, high-performance, distributed memory
- | object caching system, generic in nature, but intended for use in speeding
- | up dynamic web applications by alleviating database load.
+ | The Memcached servers used by your application. Memcached is a free and
+ | open source, high-performance, distributed memory caching system. It is
+ | generic in nature but intended for use in speeding up web applications
+ | by alleviating database load.
|
- | For more information about Memcached, check out: http://memcached.org
+ | For more information, check out: http://memcached.org
|
*/
View
54 application/config/container.php
@@ -1,54 +0,0 @@
-<?php
-
-return array(
-
- /*
- |--------------------------------------------------------------------------
- | Inversion of Control Container
- |--------------------------------------------------------------------------
- |
- | Here you may define resolvers for the Laravel inversion of control (IoC)
- | container. An IoC container provides the ability to create more flexible
- | and testable applications, as well as a convenient method of managing
- | the instantiation of complex objects.
- |
- | To register a resolver in the container, simple create add an item to
- | the array for the object with a closure that returns an instance of
- | the object.
- |
- | For example, here's how to register a resolver for a Mailer class:
- |
- | 'mailer' => function($c)
- | {
- | return new Mailer($sender, $key);
- | }
- |
- | Note that the container instance itself is passed into the resolver,
- | allowing you to continue to resolve dependencies within the resolver
- | itself. This allows you to easily resolve nested dependencies.
- |
- | When creating controller instances, Laravel will check to see if a
- | resolver has been registered for the controller. If it has, it will
- | be used to create the controller instance. All controller resolvers
- | should be registered beginning using a {controllers}.{name} naming
- | convention. For example:
- |
- | 'controllers.user' => function($c)
- | {
- | return new User_Controller($c->resolve('repository'));
- | }
- |
- | Of course, sometimes you may wish to register an object as a singleton
- | Singletons are resolved by the controller the first time they are
- | resolved; however, that same resolved instance will continue to be
- | returned by the container each time it is requested. Registering an
- | object as a singleton couldn't be simpler:
- |
- | 'mailer' => array('singleton' => true, 'resolver' => function($c)
- | {
- | return new Mailer($sender, $key);
- | })
- |
- */
-
-);
View
48 application/config/database.php
@@ -7,39 +7,29 @@
| Default Database Connection
|--------------------------------------------------------------------------
|
- | The name of your default database connection.
- |
- | This connection will be the default for all database operations unless a
- | different connection is specified when performing the operation.
+ | The name of your default database connection. This connection will used
+ | as the default for all database operations unless a different name is
+ | given when performing said operation. This connection name should be
+ | listed in the array of connections below.
|
*/
- 'default' => 'sqlite',
+ 'default' => 'mysql',
/*
|--------------------------------------------------------------------------
| Database Connections
|--------------------------------------------------------------------------
|
- | All of the database connections used by your application.
- |
- | Supported Drivers: 'mysql', 'pgsql', 'sqlite'.
- |
- | Note: When using the SQLite driver, the path and "sqlite" extention will
- | be added automatically. You only need to specify the database name.
+ | All of the database connections used by your application. Many of your
+ | applications will no doubt only use one connection; however, you have
+ | the freedom to specify as many connections as you can handle.
|
- | Using a driver that isn't supported? You can still establish a PDO
- | connection. Simply specify a driver and DSN option:
+ | All database work in Laravel is done through the PHP's PDO facilities,
+ | so make sure you have the PDO drivers for your particlar database of
+ | choice installed on your machine.
|
- | 'odbc' => array(
- | 'driver' => 'odbc',
- | 'dsn' => 'your-dsn',
- | 'username' => 'username',
- | 'password' => 'password',
- | )
- |
- | Note: When using an unsupported driver, Eloquent and the fluent query
- | builder may not work as expected.
+ | Drivers: 'mysql', 'pgsql', 'sqlsrv', 'sqlite'.
|
*/
@@ -68,6 +58,14 @@
'charset' => 'utf8',
),
+ 'sqlsrv' => array(
+ 'driver' => 'sqlsrv',
+ 'host' => 'localhost',
+ 'database' => 'database',
+ 'username' => 'root',
+ 'password' => 'password',
+ ),
+
),
/*
@@ -77,11 +75,9 @@
|
| Redis is an open source, fast, and advanced key-value store. However, it
| provides a richer set of commands than a typical key-value store such as
- | APC or memcached.
- |
- | Here you may specify the hosts and ports for your Redis databases.
+ | APC or memcached. All the cool kids are using it.
|
- | For more information regarding Redis, check out: http://redis.io
+ | To get the scoop on Redis, check out: http://redis.io
|
*/
View
18 application/config/error.php
@@ -7,7 +7,7 @@
| Ignored Error Levels
|--------------------------------------------------------------------------
|
- | Here you may specify the error levels that should be ignored by the
+ | Here you simply specify the error levels that should be ignored by the
| Laravel error handler. These levels will still be logged; however, no
| information about about them will be displayed.
|
@@ -22,10 +22,11 @@
|
| Detailed error messages contain information about the file in which an
| error occurs, as well as a PHP stack trace containing the call stack.
+ | You'll want them when you're trying to debug your application.
|
- | If your application is in production, consider turning off error details
- | for enhanced security and user experience. The error stack trace could
- | contain sensitive information that should not be publicly visible.
+ | If your application is in production, you'll want to turn off the error
+ | details for enhanced security and user experience since the exception
+ | stack trace could contain sensitive information.
|
*/
@@ -56,18 +57,13 @@
|
| You may log the error message however you like; however, a simple log
| solution has been setup for you which will log all error messages to
- | a single text file within the application storage directory.
- |
- | Of course, you are free to implement more complex solutions including
- | emailing the exceptions details to your team, etc.
+ | text files within the application storage directory.
|
*/
'logger' => function($exception)
{
- $message = (string) $exception;
-
- File::append(STORAGE_PATH.'log.txt', date('Y-m-d H:i:s').' - '.$message.PHP_EOL);
+ Log::exception($exception);
},
);
View
0  laravel/config/mimes.php → application/config/mimes.php
File renamed without changes
View
21 application/config/session.php
@@ -7,12 +7,12 @@
| Session Driver
|--------------------------------------------------------------------------
|
- | The name of the session driver for your application.
+ | The name of the session driver used by your application. Since HTTP is
+ | stateless, sessions are used to simulate "state" across requests made
+ | by the same user of your application. In other words, it's how an
+ | application knows who the heck you are.
|
- | Since HTTP is stateless, sessions are used to maintain "state" across
- | multiple requests from the same user of your application.
- |
- | Supported Drivers: 'cookie', 'file', 'database', 'memcached', 'apc', 'redis'.
+ | Drivers: 'cookie', 'file', 'database', 'memcached', 'apc', 'redis'.
|
*/
@@ -23,9 +23,9 @@
| Session Database
|--------------------------------------------------------------------------
|
- | The database table on which the session should be stored.
- |
- | This option is only relevant when using the "database" session driver.
+ | The database table on which the session should be stored. It probably
+ | goes without saying that this option only matters if you are using
+ | the super slick database session driver.
|
*/
@@ -40,8 +40,9 @@
| This option specifies the probability of session garbage collection
| occuring for any given request.
|
- | For example, the default value states that garbage collection has about
- | a 2% (2 / 100) chance of occuring for any given request.
+ | For example, the default value states that garbage collection has a
+ | 2% chance of occuring for any given request to the application.
+ | Feel free to tune this to your application's size and speed.
|
*/
View
119 application/config/strings.php
@@ -0,0 +1,119 @@
+<?php
+
+return array(
+
+ /*
+ |--------------------------------------------------------------------------
+ | String Inflection
+ |--------------------------------------------------------------------------
+ |
+ | This array contains the singular and plural forms of words. It's used by
+ | the "singular" and "plural" methods on the Str class to convert a given
+ | word from singular to plural and vice versa.
+ |
+ | This simple array is in constrast to the complicated regular expression
+ | patterns used by other frameworks. We think you'll enjoy the speed and
+ | simplicity of this solution.
+ |
+ | When adding a word to the array, the key should be the singular form,
+ | while the array value should be the plural form. We've included an
+ | example to get you started!
+ |
+ */
+
+ 'inflection' => array(
+
+ 'user' => 'users',
+ 'person' => 'people',
+ 'comment' => 'comments',
+
+ ),
+
+ /*
+ |--------------------------------------------------------------------------
+ | ASCII Characters
+ |--------------------------------------------------------------------------
+ |
+ | This array contains foreign characters and their 7-bit ASCII equivalents.
+ | The array is used by the "ascii" method on the Str class to get strings
+ | ready for inclusion in a URL slug.
+ |
+ | Of course, the "ascii" method may also be used by you for whatever your
+ | application requires. Feel free to add any characters we missed, and be
+ | sure to let us know about them!
+ |
+ */
+
+ 'ascii' => array(
+
+ '/æ|ǽ/' => 'ae',
+ '/œ/' => 'oe',
+ '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|А/' => 'A',
+ '/à|á|â|ã|ä|å|ǻ|ā|ă|ą|ǎ|ª|а/' => 'a',
+ '/Б/' => 'B',
+ '/б/' => 'b',
+ '/Ç|Ć|Ĉ|Ċ|Č|Ц/' => 'C',
+ '/ç|ć|ĉ|ċ|č|ц/' => 'c',
+ '/Ð|Ď|Đ|Д/' => 'Dj',
+ '/ð|ď|đ|д/' => 'dj',
+ '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Е|Ё|Э/' => 'E',
+ '/è|é|ê|ë|ē|ĕ|ė|ę|ě|е|ё|э/' => 'e',
+ '/Ф/' => 'F',
+ '/ƒ|ф/' => 'f',
+ '/Ĝ|Ğ|Ġ|Ģ|Г/' => 'G',
+ '/ĝ|ğ|ġ|ģ|г/' => 'g',
+ '/Ĥ|Ħ|Х/' => 'H',
+ '/ĥ|ħ|х/' => 'h',
+ '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|И/' => 'I',
+ '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и/' => 'i',
+ '/Ĵ|Й/' => 'J',
+ '/ĵ|й/' => 'j',
+ '/Ķ|К/' => 'K',
+ '/ķ|к/' => 'k',
+ '/Ĺ|Ļ|Ľ|Ŀ|Ł|Л/' => 'L',
+ '/ĺ|ļ|ľ|ŀ|ł|л/' => 'l',
+ '/М/' => 'M',
+ '/м/' => 'm',
+ '/Ñ|Ń|Ņ|Ň|Н/' => 'N',
+ '/ñ|ń|ņ|ň|ʼn|н/' => 'n',
+ '/Ö|Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|О/' => 'O',
+ '/ö|ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|о/' => 'o',
+ '/П/' => 'P',
+ '/п/' => 'p',
+ '/Ŕ|Ŗ|Ř|Р/' => 'R',
+ '/ŕ|ŗ|ř|р/' => 'r',
+ '/Ś|Ŝ|Ş|Š|С/' => 'S',
+ '/ś|ŝ|ş|š|ſ|с/' => 's',
+ '/Ţ|Ť|Ŧ|Т/' => 'T',
+ '/ţ|ť|ŧ|т/' => 't',
+ '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|У/' => 'U',
+ '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|у/' => 'u',
+ '/В/' => 'V',
+ '/в/' => 'v',
+ '/Ý|Ÿ|Ŷ|Ы/' => 'Y',
+ '/ý|ÿ|ŷ|ы/' => 'y',
+ '/Ŵ/' => 'W',
+ '/ŵ/' => 'w',
+ '/Ź|Ż|Ž|З/' => 'Z',
+ '/ź|ż|ž|з/' => 'z',
+ '/Æ|Ǽ/' => 'AE',
+ '/ß/'=> 'ss',
+ '/IJ/' => 'IJ',
+ '/ij/' => 'ij',
+ '/Œ/' => 'OE',
+ '/Ч/' => 'Ch',
+ '/ч/' => 'ch',
+ '/Ю/' => 'Ju',
+ '/ю/' => 'ju',
+ '/Я/' => 'Ja',
+ '/я/' => 'ja',
+ '/Ш/' => 'Sh',
+ '/ш/' => 'sh',
+ '/Щ/' => 'Shch',
+ '/щ/' => 'shch',
+ '/Ж/' => 'Zh',
+ '/ж/' => 'zh',
+
+ ),
+
+);
View
6 application/controllers/home.php
@@ -7,10 +7,10 @@ class Home_Controller extends Controller {
| The Default Controller
|--------------------------------------------------------------------------
|
- | Instead of using RESTful routes and anonymous functions, you may wish to
- | use controllers to organize your application API. You'll love them.
+ | Instead of using RESTful routes and anonymous functions, you might wish
+ | to use controllers to organize your application API. You'll love them.
|
- | To start using this controller, simply remove the default route from the
+ | To start using this controller simply remove the default route from the
| application "routes.php" file. Laravel is smart enough to find this
| controller and call the default method, which is "action_index".
|
View
68 application/filters.php
@@ -1,68 +0,0 @@
-<?php
-
-return array(
-
- /*
- |--------------------------------------------------------------------------
- | Filters
- |--------------------------------------------------------------------------
- |
- | Filters provide a convenient method for attaching functionality to your
- | routes. Filters can run either before or after a route is exectued.
- |
- | The built-in "before" and "after" filters are called before and after
- | every request to your application; however, you may create other filters
- | that can be attached to individual routes.
- |
- | Filters also make common tasks such as authentication and CSRF protection
- | a breeze. If a filter that runs before a route returns a response, that
- | response will override the route action.
- |
- | Let's walk through an example...
- |
- | First, define a filter:
- |
- | 'simple_filter' => function()
- | {
- | return 'Filtered!';
- | }
- |
- | Next, attach the filter to a route:
- |
- | 'GET /' => array('before' => 'simple_filter', function()
- | {
- | return 'Hello World!';
- | })
- |
- | Now every requests to http://example.com will return "Filtered!", since
- | the filter is overriding the route action by returning a value.
- |
- | To make your life easier, we have built authentication and CSRF filters
- | that are ready to attach to your routes. Enjoy.
- |
- */
-
- 'before' => function()
- {
- // Do stuff before every request to your application.
- },
-
-
- 'after' => function($response)
- {
- // Do stuff after every request to your application.
- },
-
-
- 'auth' => function()
- {
- if (Auth::guest()) return Redirect::to_login();
- },
-
-
- 'csrf' => function()
- {
- if (Request::forged()) return Response::error('500');
- },
-
-);
View
4 application/language/en/pagination.php
@@ -8,8 +8,8 @@
|--------------------------------------------------------------------------
|
| The following language lines are used by the paginator library to build
- | the pagination links. They may be easily changed by the developer to
- | anything they wish.
+ | the pagination links. You're free to change them to anything you want.
+ | If you come up with something more exciting, let us know.
|
*/
View
15 application/language/en/validation.php
@@ -8,11 +8,12 @@
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
- | with something more reader friendly, such as "E-Mail Address" instead
- | of "email".
+ | with something more reader friendly such as "E-Mail Address" instead
+ | of "email". Your users will thank you.
|
- | The Validator class will automatically search this array of lines when
- | attempting to replace the :attribute place-holder in error messages.
+ | The Validator class will automatically search this array of lines it
+ | is attempting to replace the :attribute place-holder in messages.
+ | It's pretty slick. We think you'll like it.
|
*/
@@ -28,9 +29,9 @@
| such as the size (max, min, between) rules. These versions are used
| for different input types such as strings and files.
|
- | These language lines may be easily changed by the developer to provide
- | custom error messages in their application. Error messages for custom
- | validation rules may also be added to this file.
+ | These language lines may be easily changed to provide custom error
+ | messages in your application. Error messages for custom validation
+ | rules may also be added to this file.
|
*/
View
0  application/migrations/.gitignore
No changes.
View
119 application/routes.php
@@ -1,42 +1,87 @@
<?php
-return array(
+/*
+|--------------------------------------------------------------------------
+| Application Routes
+|--------------------------------------------------------------------------
+|
+| Simply tell Laravel the HTTP verbs and URIs it should respond to. It is a
+| breeze to setup your applications using Laravel's RESTful routing, and it
+| is perfectly suited for building both large applications and simple APIs.
+| Enjoy the fresh air and simplicity of the framework.
+|
+| Let's respond to a simple GET request to http://example.com/hello:
+|
+| Router::register('GET /hello', function()
+| {
+| return 'Hello World!';
+| });
+|
+| You can even respond to more than one URI:
+|
+| Router::register('GET /hello, GET /world', function()
+| {
+| return 'Hello World!';
+| });
+|
+| It's easy to allow URI wildcards using (:num) or (:any):
+|
+| Router::register('GET /hello/(:any)', function($name)
+| {
+| return "Welcome, $name.";
+| });
+|
+*/
- /*
- |--------------------------------------------------------------------------
- | Application Routes
- |--------------------------------------------------------------------------
- |
- | Simply tell Laravel the HTTP verbs and URIs it should respond to. It's a
- | piece of cake to create beautiful applications using the elegant RESTful
- | routing available in Laravel.
- |
- | Let's respond to a simple GET request to http://example.com/hello:
- |
- | 'GET /hello' => function()
- | {
- | return 'Hello World!';
- | }
- |
- | You can even respond to more than one URI:
- |
- | 'GET /hello, GET /world' => function()
- | {
- | return 'Hello World!';
- | }
- |
- | It's easy to allow URI wildcards using (:num) or (:any):
- |
- | 'GET /hello/(:any)' => function($name)
- | {
- | return "Welcome, $name.";
- | }
- |
- */
+Router::register(array('GET /', 'GET /home'), function()
+{
+ return View::make('home.index');
+});
- 'GET /' => function()
- {
- return View::make('home.index');
- },
+/*
+|--------------------------------------------------------------------------
+| Route Filters
+|--------------------------------------------------------------------------
+|
+| Filters provide a convenient method for attaching functionality to your
+| routes. The built-in "before" and "after" filters are called before and
+| after every request to your application, and you may even create other
+| filters that can be attached to individual routes.
+|
+| Let's walk through an example...
+|
+| First, define a filter:
+|
+| Filter::register('filter', function()
+| {
+| return 'Filtered!';
+| });
+|
+| Next, attach the filter to a route:
+|
+| Router::register('GET /', array('before' => 'filter', function()
+| {
+| return 'Hello World!';
+| }));
+|
+*/
-);
+{
+ // Do stuff before every request to your application...
+});
+
+Filter::register('after', function()
+{
+ // Do stuff after every request to your application...
+});
+
+Filter::register('csrf', function()
+{
+ if (Request::forged()) return Response::error('500');
+});
+
+Filter::register('auth', function()
+{
+ if (Auth::guest()) return Redirect::to('login');
+});
View
1  application/storage/cache/.gitignore
@@ -1 +0,0 @@
-*
View
1  application/storage/sessions/.gitignore
@@ -1 +0,0 @@
-*
View
1  application/storage/views/.gitignore
@@ -1 +0,0 @@
-*
View
0  application/tasks/.gitignore
No changes.
View
49 artisan
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Laravel (CLI) - A Command Line For Web Artisans
+ *
+ * @package Laravel
+ * @version 2.0.7
+ * @author Taylor Otwell <taylorotwell@gmail.com>
+ * @link http://laravel.com
+ */
+
+// --------------------------------------------------------------
+// Define the directory separator for the environment.
+// --------------------------------------------------------------
+define('DS', DIRECTORY_SEPARATOR);
+
+// --------------------------------------------------------------
+// The path to the application directory.
+// --------------------------------------------------------------
+define('APP_PATH', realpath('application').'/');
+
+// --------------------------------------------------------------
+// The path to the bundles directory.
+// --------------------------------------------------------------
+define('BUNDLE_PATH', realpath('bundles').'/');
+
+// --------------------------------------------------------------
+// The path to the storage directory.
+// --------------------------------------------------------------
+define('STORAGE_PATH', realpath('storage').'/');
+
+// --------------------------------------------------------------
+// The path to the Laravel directory.
+// --------------------------------------------------------------
+define('SYS_PATH', realpath('laravel').'/');
+
+// --------------------------------------------------------------
+// The path to the public directory.
+// --------------------------------------------------------------
+define('PUBLIC_PATH', realpath('public').'/');
+
+// --------------------------------------------------------------
+// Bootstrap the Laravel core.
+// --------------------------------------------------------------
+require SYS_PATH.'core.php';
+
+// --------------------------------------------------------------
+// Launch the Laravel "Artisan" CLI.
+// --------------------------------------------------------------
+require SYS_PATH.'cli/artisan'.EXT;
View
0  bundles/.gitignore
No changes.
View
25 changelog.md
@@ -1,30 +1,5 @@
# Laravel Change Log
-## Version 2.1.0
-
-- Fix: Multiple wildcards / regular expressions per segment are now supported.
-
-### Upgrading from 2.0.9
-
-- Replace **laravel** directory.
-
-## Version 2.0.9
-
-- Minor: Made "timestamps" method in Eloquent model protected instead of private.
-- Fix: Authentication cookies are not deleted properly when custom domains or paths are used.
-
-### Upgrading from 2.0.8
-
-- Replace **laravel** directory.
-
-## Version 2.0.8
-
-- Fix: Limited URI segments to 20 to protect against DDoS.
-
-### Upgrading from 2.0.7
-
-- Replace **laravel** directory.
-
## Version 2.0.7
- Fix: Fixed raw_where in query builder.
View
166 laravel/arr.php
@@ -1,166 +0,0 @@
-<?php namespace Laravel; use Closure;
-
-class Arr {
-
- /**
- * Get an item from an array.
- *
- * "Dot" notation may be used to dig deep into the array.
- *
- * <code>
- * // Get the $array['user']['name'] value from the array
- * $name = Arr::get($array, 'user.name');
- *
- * // Return a default from if the specified item doesn't exist
- * $name = Arr::get($array, 'user.name', 'Taylor');
- * </code>
- *
- * @param array $array
- * @param string $key
- * @param mixed $default
- * @return mixed
- */
- public static function get($array, $key, $default = null)
- {
- if (is_null($key)) return $array;
-
- foreach (explode('.', $key) as $segment)
- {
- if ( ! is_array($array) or ! array_key_exists($segment, $array))
- {
- return ($default instanceof Closure) ? call_user_func($default) : $default;
- }
-
- $array = $array[$segment];
- }
-
- return $array;
- }
-
- /**
- * Set an array item to a given value.
- *
- * The same "dot" syntax used by the "get" method may be used here.
- *
- * If no key is given to the method, the entire array will be replaced.
- *
- * <code>
- * // Set the $array['user']['name'] value on the array
- * Arr::set($array, 'user.name', 'Taylor');
- * </code>
- *
- * @param array $array
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public static function set(&$array, $key, $value)
- {
- if (is_null($key)) return $array = $value;
-
- $keys = explode('.', $key);
-
- while (count($keys) > 1)
- {
- $key = array_shift($keys);
-
- if ( ! isset($array[$key]) or ! is_array($array[$key]))
- {
- $array[$key] = array();
- }
-
- $array =& $array[$key];
- }
-
- $array[array_shift($keys)] = $value;
- }
-
- /**
- * Remove an array item from a given array.
- *
- * The same "dot" syntax used by the "get" method may be used here.
- *
- * <code>
- * // Remove the $array['user']['name'] item from the array
- * Arr::forget($array, 'user.name');
- * </code>
- *
- * @param array $array
- * @param string $key
- * @return void
- */
- public static function forget(&$array, $key)
- {
- if (is_null($key)) return;
-
- $keys = explode('.', $key);
-
- while (count($keys) > 1)
- {
- $key = array_shift($keys);
-
- if ( ! isset($array[$key]) or ! is_array($array[$key]))
- {
- return;
- }
-
- $array =& $array[$key];
- }
-
- unset($array[array_shift($keys)]);
- }
-
- /**
- * Return the first element in an array which passes a given truth test.
- *
- * <code>
- * // Return the first array element that equals "Taylor"
- * $value = Arr::first($array, function($k, $v) {return $v === 'Taylor';});
- *
- * // Return a default value if no matching element is found
- * $value = Arr::first($array, function($k, $v) {return $v === 'Taylor'}, 'Default');
- * </code>
- *
- * @param array $array
- * @param Closure $callback
- * @param mixed $default
- * @return mixed
- */
- public static function first($array, $callback, $default = null)
- {
- foreach ($array as $key => $value)
- {
- if (call_user_func($callback, $key, $value)) return $value;
- }
-
- return ($default instanceof Closure) ? call_user_func($default) : $default;
- }
-
- /**
- * Remove all array values that are contained within a given array of values.
- *
- * <code>
- * // Remove all array values that are empty strings
- * $array = Arr::without($array, '');
- *
- * // Remove all array values that are "One", "Two", or "Three"
- * $array = Arr::without($array, array('One', 'Two', 'Three'));
- * </code>
- *
- * @param array $array
- * @param array $without
- * @return array
- */
- public static function without($array, $without = array())
- {
- $without = (array) $without;
-
- foreach ((array) $array as $key => $value)
- {
- if (in_array($value, $without)) unset($array[$key]);
- }
-
- return $array;
- }
-
-}
View
67 laravel/asset.php
@@ -1,4 +1,4 @@
-<?php namespace Laravel;
+<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
class Asset {
@@ -34,7 +34,7 @@ public static function container($container = 'default')
}
/**
- * Magic Method for calling methods on the default Asset container.
+ * Magic Method for calling methods on the default container.
*
* <code>
* // Call the "styles" method on the default container
@@ -61,6 +61,13 @@ class Asset_Container {
public $name;
/**
+ * The bundle that the assets belong to.
+ *
+ * @var string
+ */
+ public $bundle = DEFAULT_BUNDLE;
+
+ /**
* All of the registered assets.
*
* @var array
@@ -83,8 +90,8 @@ public function __construct($name)
* Add an asset to the container.
*
* The extension of the asset source will be used to determine the type of
- * asset being registered (CSS or JavaScript). If you are using a non-standard
- * extension, you may use the style or script methods to register assets.
+ * asset being registered (CSS or JavaScript). When using a non-standard
+ * extension, the style/script methods may be used to register assets.
*
* <code>
* // Add an asset to the container
@@ -107,7 +114,7 @@ public function add($name, $source, $dependencies = array(), $attributes = array
{
$type = (pathinfo($source, PATHINFO_EXTENSION) == 'css') ? 'style' : 'script';
- return call_user_func(array($this, $type), $name, $source, $dependencies, $attributes);
+ return $this->$type($name, $source, $dependencies, $attributes);
}
/**
@@ -148,6 +155,29 @@ public function script($name, $source, $dependencies = array(), $attributes = ar
}
/**
+ * Returns the full-path for an asset.
+ *
+ * @param string $source
+ * @return string
+ */
+ public function path($source)
+ {
+ return Bundle::assets($this->bundle).$source;
+ }
+
+ /**
+ * Set the bundle that the container's assets belong to.
+ *
+ * @param string $bundle
+ * @return Asset_Container
+ */
+ public function bundle($bundle)
+ {
+ $this->bundle = $bundle;
+ return $this;
+ }
+
+ /**
* Add an asset to the array of registered assets.
*
* @param string $type
@@ -219,6 +249,14 @@ protected function asset($group, $name)
$asset = $this->assets[$group][$name];
+ // If the bundle source is not a complete URL, we will go ahead and prepend
+ // the bundle's asset path to the source provided with the asset. This will
+ // ensure that we attach the correct path to the asset.
+ if (filter_var($asset['source'], FILTER_VALIDATE_URL) === false)
+ {
+ $asset['source'] = Bundle::assets($this->bundle).$asset['source'];
+ }
+
return HTML::$group($asset['source'], $asset['attributes']);
}
@@ -257,7 +295,7 @@ protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
{
// If the asset has no more dependencies, we can add it to the sorted list
// and remove it from the array of assets. Otherwise, we will not verify
- // the asset's dependencies and determine if they have already been sorted.
+ // the asset's dependencies and determine if they've been sorted.
if (count($assets[$asset]['dependencies']) == 0)
{
$sorted[$asset] = $value;
@@ -289,7 +327,8 @@ protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
* 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.
+ * not a reference to the owning asset itself. If the dependency doesn't exist, no
+ * error or warning will be given. For the other cases, an exception is thrown.
*
* @param string $asset
* @param string $dependency
@@ -299,16 +338,20 @@ protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
*/
protected function dependency_is_valid($asset, $dependency, $original, $assets)
{
- if ( ! isset($original[$dependency])) return false;
-
- if ($dependency === $asset)
+ if ( ! isset($original[$dependency]))
{
- throw new \LogicException("Asset [$asset] is dependent on itself.");
+ return false;
+ }
+ elseif ($dependency === $asset)
+ {
+ throw new \Exception("Asset [$asset] is dependent on itself.");
}
elseif (isset($assets[$dependency]) and in_array($asset, $assets[$dependency]['dependencies']))
{
- throw new \LogicException("Assets [$asset] and [$dependency] have a circular dependency.");
+ throw new \Exception("Assets [$asset] and [$dependency] have a circular dependency.");
}
+
+ return true;
}
}
View
101 laravel/auth.php
@@ -7,7 +7,7 @@ class Auth {
*
* @var object
*/
- protected static $user;
+ public static $user;
/**
* The key used when storing the user ID in the session.
@@ -48,12 +48,6 @@ public static function check()
/**
* Get the current user of the application.
*
- * This method will call the "user" closure in the auth configuration file.
- * If the user is not authenticated, null will be returned by the methd.
- *
- * If no user exists in the session, the method will check for a "remember me"
- * cookie and attempt to login the user based on the value of that cookie.
- *
* <code>
* // Get the current user of the application
* $user = Auth::user();
@@ -62,20 +56,26 @@ public static function check()
* $email = Auth::user()->email;
* </code>
*
- * @return object
+ * @return object|null
*/
public static function user()
{
if ( ! is_null(static::$user)) return static::$user;
- $id = IoC::core('session')->get(Auth::user_key);
+ $id = Session::get(Auth::user_key);
- static::$user = call_user_func(Config::get('auth.user'), $id);
+ // To retrieve the user, we'll first attempt to use the "user" Closure
+ // defined in the auth configuration file, passing in the ID. The user
+ // Closure gives the developer a ton of freedom surrounding how the
+ // user is actually retrieved.
+ $config = Config::get('auth');
- // If the user was not found in the database, but a "remember me" cookie
- // exists, we will attempt to recall the user based on the cookie value.
- // Since all cookies contain a fingerprint hash verifying that the have
- // not been modified on the client, we should be able to trust it.
+ static::$user = call_user_func($config['user'], $id);
+
+ // If the user wasn't found in the database but a "remember me" cookie
+ // exists, we'll attempt to recall the user based on the cookie value.
+ // Since all cookies contain a fingerprint hash verifying that they
+ // haven't changed, we can trust it.
$recaller = Cookie::get(Auth::remember_key);
if (is_null(static::$user) and ! is_null($recaller))
@@ -94,13 +94,17 @@ public static function user()
*/
protected static function recall($recaller)
{
- // When the "remember me" cookie is stored, it is encrypted and contains the
- // user's ID and a long, random string. The ID and string are separated by
- // a pipe character. Since we exploded the decrypted string, we can just
- // pass the first item in the array to the user Closure.
+ // When the remember me cookie is stored, it is encrypted and contains
+ // the user's ID and a long, random string. The segments are separated
+ // by a pipe character so we'll explode on that.
$recaller = explode('|', Crypter::decrypt($recaller));
- if ( ! is_null($user = call_user_func(Config::get('auth.user'), $recaller[0])))
+ // We'll pass the ID that was stored in the cookie into the same user
+ // Closure that is used by the "user" method. If the method returns
+ // a user, we will log them into the application.
+ $user = call_user_func(Config::get('auth.user'), $recaller[0]);
+
+ if ( ! is_null($user))
{
static::login($user);
@@ -111,12 +115,13 @@ protected static function recall($recaller)
/**
* Attempt to log a user into the application.
*
- * If the credentials are valid, the user will be logged into the application
- * and their user ID will be stored in the session via the "login" method.
+ * <code>
+ * // Attempt to log a user into the application
+ * $success = Auth::attempt('username', 'password');
*
- * The user may also be "remembered", which will keep the user logged into the
- * application for one year or until they logout. The user is remembered via
- * an encrypted cookie.
+ * // Attempt to login a user and set the "remember me" cookie
+ * Auth::attempt('username', 'password', true);
+ * </code>
*
* @param string $username
* @param string $password
@@ -127,32 +132,35 @@ public static function attempt($username, $password = null, $remember = false)
{
$config = Config::get('auth');
- $user = call_user_func($config['attempt'], $username, $password, $config);
+ // When attempting to login the user, we will call the "attempt" closure
+ // from the configuration file. This gives the developer the freedom to
+ // authenticate based on the needs of their application.
+ //
+ // All of the password hashing and checking and left totally up to the
+ // developer, as this gives them the freedom to use any hashing scheme
+ // or authentication provider they wish.
+ $user = call_user_func($config['attempt'], $username, $password);
- if ( ! is_null($user))
- {
- static::login($user, $remember);
+ // If the user credentials were authenticated by the closure, we will
+ // log the user into the application, which will store their user ID
+ // in the session for subsequent requests.
+ if (is_null($user)) return false;
- return true;
- }
+ static::login($user, $remember);
- return false;
+ return true;
}
/**
* Log a user into the application.
*
- * An object representing the user or an integer user ID may be given to the method.
- * If an object is given, the object must have an "id" property containing the user
- * ID as it is stored in the database.
- *
* <code>
- * // Login a user by passing a user object
- * Auth::login($user);
- *
* // Login the user with an ID of 15
* Auth::login(15);
*
+ * // Login a user by passing a user object
+ * Auth::login($user);
+ *
* // Login a user and set a "remember me" cookie
* Auth::login($user, true);
* </code>
@@ -167,11 +175,11 @@ public static function login($user, $remember = false)
if ($remember) static::remember($id);
- IoC::core('session')->put(Auth::user_key, $id);
+ Session::put(Auth::user_key, $id);
}
/**
- * Set a cookie so that users are "remembered" and don't need to login.
+ * Set a cookie so that the user is "remembered".
*
* @param string $id
* @return void
@@ -183,7 +191,7 @@ protected static function remember($id)
// This method assumes the "remember me" cookie should have the same
// configuration as the session cookie. Since this cookie, like the
// session cookie, should be kept very secure, it's probably safe
- // to assume the settings are the same.
+ // to assume the settings are the same for this cookie.
$config = Config::get('session');
extract($config, EXTR_SKIP);
@@ -194,14 +202,13 @@ protected static function remember($id)
/**
* Log the current user out of the application.
*
- * The "logout" closure in the authenciation configuration file will be
- * called. All authentication cookies will be deleted and the user ID
- * will be removed from the session.
- *
* @return void
*/
public static function logout()
{
+ // We will call the "logout" closure first, which gives the developer
+ // the chance to do any clean-up or before the user is logged out of
+ // the application. No action is taken by default.
call_user_func(Config::get('auth.logout'), static::user());
static::$user = null;
@@ -213,11 +220,9 @@ public static function logout()
// When forgetting the cookie, we need to also pass in the path and
// domain that would have been used when the cookie was originally
// set by the framework, otherwise it will not be deleted.
- Cookie::forget(Auth::user_key, $path, $domain, $secure);
-
Cookie::forget(Auth::remember_key, $path, $domain, $secure);
- IoC::core('session')->forget(Auth::user_key);
+ Session::forget(Auth::user_key);
}
}
View
185 laravel/autoloader.php
@@ -1,4 +1,4 @@
-<?php namespace Laravel;
+<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');
class Autoloader {
@@ -10,176 +10,143 @@ class Autoloader {
public static $mappings = array();
/**
- * The PSR-0 compliant libraries registered with the loader.
+ * All of the class aliases registered with the auto-loader.
*
* @var array
*/
- public static $libraries = array();
+ public static $aliases = array();
/**
- * The paths to be searched by the loader.
+ * The directories that use the PSR-0 naming convention.
*
* @var array
*/
- protected static $paths = array(MODEL_PATH, LIBRARY_PATH);
+ public static $psr = array();
/**
* Load the file corresponding to a given class.
*
- * This method is registerd in the core bootstrap file as an SPL Autoloader.
+ * This method is registerd in the bootstrap file as an SPL auto-loader.
*
* @param string $class
* @return void
*/
public static function load($class)
{
- if (isset(Config::$items['application']['aliases'][$class]))
+ // First, we will check to see if the class has been aliased. If it has,
+ // we will register the alias, which may cause the auto-loader to be
+ // called again for the "real" class name.
+ if (isset(static::$aliases[$class]))
{
- return class_alias(Config::$items['application']['aliases'][$class], $class);
+ class_alias(static::$aliases[$class], $class);
}
- if ( ! is_null($path = static::find($class)))
+ // All classes in Laravel are staticly mapped. There is no crazy search
+ // routine that digs through directories. It's just a simple array of
+ // class to file path maps for ultra-fast file loading.
+ elseif (isset(static::$mappings[$class]))
{
- require $path;
- }
- }
-
- /**
- * Determine the file path associated with a given class name.
- *
- * @param string $class
- * @return string
- */
- protected static function find($class)
- {
- // First we will look for the class in the hard-coded class mappings, since
- // this is the fastest way to resolve a class name to its associated file.
- // This saves us from having to search through the file system manually.
- if (isset(static::$mappings[$class]))
- {
- return static::$mappings[$class];
+ require static::$mappings[$class];
}
- // If the library has been registered as a PSR-0 compliant library, we will
- // load the library according to the PSR-0 naming standards, which state that
- // namespaces and underscores indicate the directory hierarchy of the class.
- if (in_array(static::library($class), static::$libraries))
+ // If the class is namespaced to an existing bundle and the bundle has
+ // not been started, we will start the bundle and attempt to load the
+ // class file again. If that fails, an error will be thrown by PHP.
+ //
+ // This allows bundle classes to be loaded by the auto-loader before
+ // their class mappings have actually been registered; however, it
+ // is up to the bundle developer to namespace their classes to
+ // match the name of their bundle.
+ elseif (($slash = strpos($class, '\\')) !== false)
{
- return LIBRARY_PATH.str_replace(array('\\', '_'), '/', $class).EXT;
- }
-
- // Next we will search through the common Laravel paths for the class file.
- // The Laravel libraries and models directories will be searched according
- // to the Laravel class naming standards.
- $file = strtolower(str_replace('\\', '/', $class));
+ $bundle = substr($class, 0, $slash);
- foreach (static::$paths as $path)
- {
- if (file_exists($path = $path.$file.EXT))
+ // It's very important that we make sure the bundle has not been
+ // started here. If we don't, we'll end up in an infinite loop
+ // attempting to load a bundle's class.
+ if (Bundle::exists($bundle) and ! Bundle::started($bundle))
{
- return $path;
+ Bundle::start($bundle);
+
+ static::load($class);
}
}
- // Since not all controllers will be resolved by the controller resolver,
- // we will do a quick check in the controller directory for the class.
- // For instance, since base controllers would not be resolved by the
- // controller class, we will need to resolve them here.
- if (file_exists($path = static::controller($class)))
- {
- return $path;
- }
+ static::load_psr($class);
}
/**
- * Extract the "library" name from the given class.
- *
- * The library name is essentially the namespace, or the string that preceeds
- * the first PSR-0 separator. PSR-0 states that namespaces or undescores may
- * be used to indicate the directory structure in which the file resides.
+ * Attempt to resolve a class using the PSR-0 standard.
*
* @param string $class
- * @return string
+ * @return void
*/
- protected static function library($class)
+ protected static function load_psr($class)
{
- if (($separator = strpos($class, '\\')) !== false)
- {
- return substr($class, 0, $separator);
- }
- elseif (($separator = strpos($class, '_')) !== false)
+ // The PSR-0 standard indicates that class namespace slashes or
+ // underscores should be used to indicate the directory tree in
+ // which the class resides.
+ $file = str_replace(array('\\', '_'), '/', $class);
+
+ // Once we have formatted the class name, we will simply spin
+ // through the registered PSR-0 directories and attempt to
+ // locate and load the class into the script.
+ foreach (static::$psr as $directory)
{
- return substr($class, 0, $separator);
+ if (file_exists($path = $directory.strtolower($file).EXT))
+ {
+ return require $path;
+ }
+ elseif (file_exists($path = $directory.$file.EXT))
+ {
+ return require $path;
+ }
}
}
/**
- * Translate a given controller class name into the corresponding file name.
- *
- * The controller suffix will be removed, and the underscores will be translated
- * into directory slashes. Of course, the entire class name will be converted to
- * lower case as well.
+ * Register an array of class to path mappings.
*
* <code>
- * // Returns "user/profile"...
- * $file = static::controller('User_Profile_Controller');
+ * // Register a class mapping with the Autoloader
+ * Autoloader::map(array('User' => APP_PATH.'models/user.php'));
* </code>
*
- * @param string $class
- * @return string
+ * @param array $mappings
+ * @return void
*/
- protected static function controller($class)
+ public static function map($mappings)
{
- $controller = str_replace(array('_', '_Controller'), array('/', ''), $class);
-
- return CONTROLLER_PATH.strtolower($controller).EXT;
+ static::$mappings = array_merge(static::$mappings, $mappings);
}
/**
- * Register an array of class to path mappings.
- *
- * The mappings will be used to resolve file paths from class names when
- * a class is lazy loaded through the Autoloader, providing a faster way
- * of resolving file paths than the typical file_exists method.
- *
- * <code>
- * // Register a class mapping with the Autoloader
- * Autoloader::maps(array('User' => MODEL_PATH.'user'.EXT));
- * </code>
+ * Register a class alias with the auto-loader.
*
- * @param array $mappings
+ * @param string $class
+ * @param string $alias
* @return void
*/
- public static function maps($mappings)
+ public static function alias($class, $alias)
{
- foreach ($mappings as $class => $path)
- {
- static::$mappings[$class] = $path;
- }
+ static::$aliases[$alias] = $class;
}
/**
- * Register PSR-0 libraries with the Autoloader.
- *
- * The library names given to this method should match directories within
- * the application libraries directory. This method provides an easy way
- * to indicate that some libraries should be loaded using the PSR-0
- * naming conventions instead of the Laravel conventions.
- *
- * <code>
- * // Register the "Assetic" library with the Autoloader
- * Autoloader::libraries('Assetic');
- *
- * // Register several libraries with the Autoloader
- * Autoloader::libraries(array('Assetic', 'Twig'));
- * </code>
+ * Register directories to be searched as a PSR-0 library.
*
- * @param array $libraries
+ * @param string|array $directory
* @return void
*/
- public static function libraries($libraries)
+ public static function psr($directory)
{
- static::$libraries = array_merge(static::$libraries, (array) $libraries);
+ $directories = array_map(function($directory)
+ {
+ return rtrim($directory, '/').'/';
+
+ }, (array) $directory);
+
+ static::$psr = array_unique(array_merge(static::$psr, $directories));
}
}
View
49 laravel/benchmark.php
@@ -1,49 +0,0 @@
-<?php namespace Laravel;
-
-class Benchmark {
-
- /**
- * All of the benchmark starting times.
- *
- * @var array
- */
- protected static $marks = array();
-
- /**
- * Start a benchmark starting time.
- *
- * @param string $name
- * @return void
- */
- public static function start($name)
- {
- static::$marks[$name] = microtime(true);
- }
-
- /**
- * Get the elapsed time in milliseconds since starting a benchmark.
- *
- * @param string $name
- * @return float
- */
- public static function check($name)
- {
- if (array_key_exists($name, static::$marks))
- {
- return (float) number_format((microtime(true) - static::$marks[$name]) * 1000, 2);
- }
-
- return (float) 0.0;
- }
-
- /**
- * Get the total memory usage in megabytes.
- *
- * @return float
- */
- public static function memory()
- {
- return (float) number_format(memory_get_usage() / 1024 / 1024, 2);
- }
-
-}
View
10 laravel/blade.php
@@ -1,4 +1,4 @@
-<?php namespace Laravel;
+<?php namespace Laravel; defined('APP_PATH') or die('No direct script access.');