Readouble

Laravel 5.dev アップグレードガイド

4.2から5.0へのアップグレードUpgrading To 5.0 From 4.2

新しくインストール、その後で移行Fresh Install, Then Migrate

推奨するアップグレード方法は、新しくLaravel5.0をインストールし、それから4.2サイト独自のファイルを新しくインストールした環境へコピーすることです。コピーするファイルにはコントローラー、ルート、Eloqモデル、Artisanコマンド、アセット、その他あなたのアプリケーション限定のコードを含みます。The recommended method of upgrading is to create a new Laravel 5.0 install and then to copy your 4.2 site's unique application files into the new application. This would include controllers, routes, Eloquent models, Artisan commands, assets, and other code specific to your application.

開始するために、ローカル環境の新しいディレクトリーへLaravel5アプリケーションをインストールしてください。各手順の詳細は、以降で紹介します。To start, install a new Laravel 5 application[/docs/master/installation] into a fresh directory in your local environment. We'll discuss each piece of the migration process in further detail below.

Composerの依存とパッケージComposer Dependencies & Packages

追加しているComposerの依存パッケージを5.0アプリケーションへコピーするのを忘れないでください。SDKのような、サードパーティのコードも忘れずに。Don't forget to copy any additional Composer dependencies into your 5.0 application. This includes third-party code such as SDKs.

最初のリリース時、Laravel限定のパッケージはLaravel5と互換性がないかも知れません。Laravel5向きの対応バージョンが用意されるか、メンテナーに確認しましょう。Composerの依存パッケージをアプリケーションに追加したら、composer updataを実行する必要があります。Some Laravel-specific packages may not be compatible with Laravel 5 on initial release. Check with your package's maintainer to determine the proper version of the package for Laravel 5. Once you have added any additional Composer dependencies your application needs, run composer update.

名前空間Namespacing

Laravel4のデフォルトでは、アプリケーションのコードに名前空間は使用されていません。そのため、例えば、全Eloquentモデルとコントローラーは、ただ「グローバル」な名前空間下に置かれています。手早く移行するには、Laravel5でも同様にグローバル名前空間下へ、それらのクラスを設置しましょう。By default, Laravel 4 applications did not utilize namespacing within your application code. So, for example, all Eloquent models and controllers simply lived in the "global" namespace. For a quicker migration, you can simply leave these classes in the global namespace in Laravel 5 as well.

設定Configuration

環境変数の移行Migrating Environment Variables

新しい.env.exampleファイルを.envへコピーします。古いバージョンの.env.phpファイルに該当します。APP_ENVAPP_KEY(暗号化キー)、データベース接続情報、キャッシュやセッションのドライバーのような値を適切に設置してください。Copy the new .env.example file to .env, which is the 5.0 equivalent of the old .env.php file. Set any appropriate values there, like your APP_ENV and APP_KEY (your encryption key), your database credentials, and your cache and session drivers.

さらに、古い.env.phpファイル中で変更した値を.env(ローカル環境で本当に使用される値)と.env.example(他のチームメンバーに参考にしてもらう値)にコピーします。Additionally, copy any custom values you had in your old .env.php file and place them in both .env (the real value for your local environment) and .env.example (a sample instructional value for other team members).

環境設定の詳細は、ドキュメントを読んでください。For more information on environment configuration, view the full documentation[/docs/master/configuration#environment-configuration].

注意: Laravel5アプリケーションを本番サーバーへデプロイする前に、適切な値を設置した.envファイルを用意しておく必要があります。Note: You will need to place the appropriate .env file and values on your production server before deploying your Laravel 5 application.

設定ファイルConfiguration Files

Laravel5.0では、特定の環境のために設定ファイルを指定する、app/config/{環境名}/ディレクトリー構造はもう使われません。代わりに、様々な環境に用意する.envへ設定値を移動します。それから、設定ファイル中でenv('キー', 'デフォルト値')を使用して、値にアクセスします。config/database.php設定ファイルに設定例があります。Laravel 5.0 no longer uses app/config/{environmentName}/ directories to provide specific configuration files for a given environment. Instead, move any configuration values that vary by environment into .env, and then access them in your configuration files using env('key', 'default value'). You will see examples of this in the config/database.php configuration file.

configディレクトリー下の設定ファイルには、全環境に渡り変更しない値を直接設置するか、環境ごとに変化する値をロードするために、env()を使うかの、どちらかで設定値を指定します。Set the config files in the config/ directory to represent either the values that are consistent across all of your environments, or set them to use env() to load values that vary by environment.

.envファイルにキーを追加したら、同様に参考値を.env.exampleファイルへ追加するのを忘れないでください。これにより、あなたのチームメンバーが自分の.envファイルを作成しやすくなります。Remember, if you add more keys to .env file, add sample values to the .env.example file as well. This will help your other team members create their own .env files.

ルートRoutes

古いroutes.phpを新しいapp/Http/routes.phpへ、コピー&貼付けしてください。Copy and paste your old routes.php file into your new app/Http/routes.php.

コントローラーControllers

次に、全コントローラーをapp/Http/Controllersディレクトリーへ移動します。このガイドでは名前空間を利用した以降を行わないため、composer.jsonファイルのclassmapディレクティブへ、app/Http/Controllersを追加してください。次に、app/Http/Controllers/Controller.php抽象ベースクラスから、名前空間を削除します。移行するコントローラーはこのベースクラスを拡張していることを確認してください。Next, move all of your controllers into the app/Http/Controllers directory. Since we are not going to migrate to full namespacing in this guide, add the app/Http/Controllers directory to the classmap directive of your composer.json file. Next, you can remove the namespace from the abstract app/Http/Controllers/Controller.php base class. Verify that your migrated controllers are extending this base class.

app/Providers/RouteServiceProvider.phpファイルの中で、namespaceプロパティをnullに設定してください。In your app/Providers/RouteServiceProvider.php file, set the namespace property to null.

ルートフィルターRoute Filters

フィルターの定義をapp/filters.phpから、app/Providers/RouteServiceProvider.phpboot()メソッドの中へコピーします。app/Providers/RouteServiceProvider.phpuse Illuminate\Support\Facades\Route;の1行を追加し、Routeファサードを使い続けられるようにします。Copy your filter bindings from app/filters.php and place them into the boot() method of app/Providers/RouteServiceProvider.php. Add use Illuminate\Support\Facades\Route; in the app/Providers/RouteServiceProvider.php in order to continue using the Route Facade.

authcsrfのような、Laravel4デフォルトフィルターは移動しないでください。ミドルウェアとしてLaravel5に用意されています。ルートやコントローラーで、古いデフォルトフィルターの使用箇所(例えば、['before' => 'auth'])を新しいミドルウェアを使用するように書き換えてください。(例えば、['middleware' => 'auth']You do not need to move over any of the default Laravel 4.0 filters such as auth and csrf; they're all here, but as middleware. Edit any routes or controllers that reference the old default filters (e.g. ['before' => 'auth']) and change them to reference the new middleware (e.g. ['middleware' => 'auth'].)

フィルターはLaravel5でも廃止されていません。カスタムフィルターを定義して、beforeafterを使用し指定できます。Filters are not removed in Laravel 5. You can still bind and use your own custom filters using before and after.

グローバルCSRFGlobal CSRF

デフォルトで、CSRF保護が、全ルートで有効になりました。これを無効にするか、特定のルートだけに手動で有効にしたいのでしたら、以下の行をApp\Http\Kernelファイル中のmiddleware配列から削除してください。By default, CSRF protection[/docs/master/routing#csrf-protection] is enabled on all routes. If you'd like to disable this, or only manually enable it on certain routes, remove this line from App\Http\Kernel's middleware array:

'App\Http\Middleware\VerifyCsrfToken',

他で使用する場合は、次の1行を$routeMiddlewareに追加します。If you want to use it elsewhere, add this line to $routeMiddleware:

'csrf' => 'App\Http\Middleware\VerifyCsrfToken',

これで、個別のルート/コントローラーに対し、['middleware' => 'csrf']を指定することで、ミドルウェアを追加できるようになります。ミドルウェアの詳細は、ドキュメントを参照してください。Now you can add the middleware to individual routes / controllers using ['middleware' => 'csrf'] on the route. For more information on middleware, consult the full documentation[/docs/master/middleware].

EloquentモデルEloquent Models

Eloquentモデルを設置するために、app/Modelsディレクトリーを作成することもできます。その場合、このディレクトリーをcomposer.jsonclassmapディレクティブへ追加してください。Feel free to create a new app/Models directory to house your Eloquent models. Again, add this directory to the classmap directive of your composer.json file.

SoftDeletingTraitを使用しているモデルでは、Illuminate\Database\Eloquent\SoftDeletesを使うように変更します。Update any models using SoftDeletingTrait to use Illuminate\Database\Eloquent\SoftDeletes.

EloquentキャッシュEloquent Caching

Eloquentは、クエリー結果をキャッシュするためのrememberメソッドを提供しなくなりました。Cache::remember機能を使用し、手動でクエリーをキャッシュする必要があります。キャッシュの詳細は、ドキュメントに全て記載されています。Eloquent no longer provides the remember method for caching queries. You now are responsible for caching your queries manually using the Cache::remember function. For more information on caching, consult the full documentation[/docs/master/cache].

User認証モデルUser Authentication Model

UserモデルをLaravel5の認証システム向けにアップグレードするには、以下の指示に従ってください。To upgrade your User model for Laravel 5's authentication system, follow these instructions:

useブロックから、以下の行を削除するDelete the following from your use block:

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

useブロックに、以下の行を追加するAdd the following to your use block:

use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

UserInterfaceとRemindableInterfaceインターフェイスを削除するRemove the UserInterface and RemindableInterface interfaces.

クラスで以下のインターフェイスを実装宣言するMark the class as implementing the following interfaces:

implements AuthenticatableContract, CanResetPasswordContract

クラスの宣言で、以下のトレイトを取り込むInclude the following traits within the class declaration:

use Authenticatable, CanResetPassword;

Cashierの変更Cashier User Changes

Laravel Cashierで使用されていたトレイトとインターフェイスの名前が変更されました。BillableTraitの代わりに、Laravel\Cashier\Billableトレイトを使用してください。それとLarave\Cashier\BillableInterfaceの代わりに、Laravel\Cashier\Contracts\Billableインターフェイスを実装します。他の名前の変更はありません。The name of the trait and interface used by Laravel Cashier[/docs/master/billing] has changed. Instead of using BillableTrait, use the Laravel\Cashier\Billable trait. And, instead of Larave\Cashier\BillableInterface implement the Laravel\Cashier\Contracts\Billable interface instead. No other method changes are required.

ArtisanコマンドArtisan Commands

古いapp/commandsディレクトリーからコマンドクラスを全部、新しいapp/Console/Commandsディレクトリーへ移動します。次に、composer.jsonファイルのclassmapディレクティブに、app/Console/Commandsを追加します。Move all of your command classes from your old app/commands directory to the new app/Console/Commands directory. Next, add the app/Console/Commands directory to the classmap directive of your composer.json file.

それから、start/artisan.phpでリストしていたArtisanコマンドをapp/Console/Kernel.phpcommand配列へコピーします。Then, copy your list of Artisan commands from start/artisan.php into the command array of the app/Console/Kernel.php file.

データベースマイグレーションと初期値設定Database Migrations & Seeds

データベースにusersテーブルが既に存在しているでしょうから、Laravel5.0に含まれている2つのマイグレーションを削除します。Delete the two migrations included with Laravel 5.0, since you should already have the users table in your database.

app/database/migrationsディレクトリーのマイグレートクラスを、新しいdatabase/migrationsへ移動します。初期値設定(seed)クラスをapp/database/seedsから、database/seedsへ移動します。Move all of your migration classes from the old app/database/migrations directory to the new database/migrations. All of your seeds should be moved from app/database/seeds to database/seeds.

グローバルIoC結合Global IoC Bindings

start/global.phpの中のIoC結合は全て、app/Providers/AppServiceProvider.phpファイルのregisterメソッドへ移動します。Appファサードをインポートする必要があります。If you have any IoC[/docs/master/container] bindings in start/global.php, move them all to the register method of the app/Providers/AppServiceProvider.php file. You may need to import the App facade.

そうした結合定義をカテゴリー毎に別々のサービスプロバイダーへ分割する選択肢もあります。Optionally, you may break these bindings up into separate service providers by category.

ビューViews

app/views中のビューを新しいresources/viewsディレクトリーへ移動します。Move your views from app/views to the new resources/views directory.

Bladeタグ変更Blade Tag Changes

デフォルトでもセキュリティーを強化するために、Laravel5.0では{{ }}{{{ }}}の両Blade記法で出力がエスケープされます。新しい{!! !!}記法により、出力をエスケープせずにそのまま表示します。アプリケーションをアップデートする場合の一番安全な選択肢は、明らかにそのまま出力をしても安全なところでだけで、新しい{!! !!}記法を使うことでしょう。For better security by default, Laravel 5.0 escapes all output from both the {{ }} and {{{ }}} Blade directives. A new {!! !!} directive has been introduced to display raw, unescaped output. The most secure option when upgrading your application is to only use the new {!! !!} directive when you are certain that it is safe to display raw output.

しかし、古いBlade記法を使わなくてはならないのでしたら、AppServiceProvider@registerの最後に、以下の数行を追加してください。However, if you must use the old Blade syntax, add the following lines at the bottom of AppServiceProvider@register:

\Blade::setRawTags('{{', '}}');
\Blade::setContentTags('{{{', '}}}');
\Blade::setEscapedContentTags('{{{', '}}}');

これは簡単に行うべきではありません。XSS攻撃に対しアプリケーションを脆弱にしてしまうかもしれません。また、{{--を使用したコメントは廃止されました。This should not be done lightly, and may make your application more vulnerable to XSS exploits. Also, comments with {{-- will no longer work.

言語ファイルTranslation Files

app/lang下の言語ファイルは、新しいresources/langディレクトリーへ移動します。Move your language files from app/lang to the new resources/lang directory.

PublicディレクトリーPublic Directory

4.2アプリケーションのpublicディレクトリーから、公開しているアセットを新しいアプリケーションのpublicディレクトリーへコピーします。5.0バージョンのindex.phpは変更しないように気をつけてください。Copy your application's public assets from your 4.2 application's public directory to your new application's public directory. Be sure to keep the 5.0 version of index.php.

テストTests

app/testsからテストを、新しいtestsディレクトリーへ移動します。Move your tests from app/tests to the new tests directory.

その他のファイルMisc. Files

プロジェクトの他のファイルをコピーしましょう。例えば、.scrutinizer.ymlbower.json、その他の似たようなツールの設定ファイルなどです。Copy in any other files in your project. For example, .scrutinizer.yml, bower.json and other similar tooling configuration files.

SassやLess、CoffeeScriptをお好きな場所へ移動しましょう。resources/assetsディレクトリーがデフォルトの場所として最適でしょう。You may move your Sass, Less, or CoffeeScript to any location you wish. The resources/assets directory could be a good default location.

FormとHTMLヘルパForm & HTML Helpers

FromかHTMLヘルパを使用しているのでしたら、class 'Form' not foundclass 'Html' not foundのエラーを目にすることになります。これを修正するには、composer.jsonファイルのrequireセクションに、"illuminate/html": "~5.0"を追加してください。If you're using Form or HTML helpers, you will see an error stating class 'Form' not found or class 'Html' not found. To fix this, add "illuminate/html": "~5.0" to your composer.json file's require section.

さらに、FormとHTMLのファサード、サービスプロバイダーを追加する必要があります。config/app.phpを編集し、providers配列に以下の1行を追加します。You'll also need to add the Form and HTML facades and service provider. Edit config/app.php, and add this line to the 'providers' array:

'Illuminate\Html\HtmlServiceProvider',

次に、aliases配列へ以下を追加します。Next, add these lines to the 'aliases' array:

'Form'      => 'Illuminate\Html\FormFacade',
'Html'      => 'Illuminate\Html\HtmlFacade',

CacheManagerCacheManager

Laravelのキャッシュでファサードを使用せず、Illuminate\Cache\CacheManagerをコードで注入している場合、代わりにIlluminate\Contracts\Cache\Repositoryを注入してください。If your application code was injecting Illuminate\Cache\CacheManager to get a non-Facade version of Laravel's cache, inject Illuminate\Contracts\Cache\Repository instead.

ペジネーションPagination

$paginator->links()の呼び出しを$paginator->render()へ変更してください。Replace any calls to $paginator->links() with $paginator->render().

BeanstalkキューBeanstalk Queuing

Laravel5.0では、"pda/pheanstalk": "~2.1"の代わりに、"pda/pheanstalk": "~3.0"が必要になります。Laravel 5.0 now requires "pda/pheanstalk": "~3.0" instead of "pda/pheanstalk": "~2.1".

RemoteRemote

Remoteコンポーネントは廃止されました。The Remote component has been deprecated.

WorkbenchWorkbench

Workbenchコンポーネントは廃止されました。The Workbench component has been deprecated.

4.1から4.2へのアップグレードUpgrading To 4.2 From 4.1

PHP 5.4 PHP 5.4

Laravel4.2を動作させるにはPHP 5.4.0以上が必要です。Laravel 4.2 requires PHP 5.4.0 or greater.

暗号化のデフォルトEncryption Defaults

app/config/app.php設定ファイルに、新しいcipherオプションが追加されました。このオプションの値は、MCRYPT_RIJNDAEL_256にすべきでしょう。Add a new cipher option in your app/config/app.php configuration file. The value of this option should be MCRYPT_RIJNDAEL_256.

'cipher' => MCRYPT_RIJNDAEL_256

この設定は、Laravelの暗号機能により使用される、デフォルトcipherをコントロールするために使用されます。This setting may be used to control the default cipher used by the Laravel encryption facilities.

注意: Laravel4.2では、最も安全な暗号化であると考えられる、MCRYPT_RIJNDAEL_128 (AES)がデフォルトの暗号化です。cipherをMCRYPT_RIJNDAEL_256へ戻すことが必要になるのは、Laravel4.1以前のバージョンで暗号化されたクッキー/値を解読する場合です。Note: In Laravel 4.2, the default cipher is MCRYPT_RIJNDAEL_128 (AES), which is considered to be the most secure cipher. Changing the cipher back to MCRYPT_RIJNDAEL_256 is required to decrypt cookies/values that were encrypted in Laravel <= 4.1

ソフトデリートは、トレイトを使用するようになりましたSoft Deleting Models Now Use Traits

モデルのソフトデリートを使用している場合、softDeletesプロパティーは必要なくなりました。SoftDeletingTraitを次のように使用してください。If you are using soft deleting models, the softDeletes property has been removed. You must now use the SoftDeletingTrait like so:

use Illuminate\Database\Eloquent\SoftDeletingTrait;

class User extends Eloquent {
	use SoftDeletingTrait;
}

それから、datesプロパティーにdeleted_atカラムを追記してください。You must also manually add the deleted_at column to your dates property:

class User extends Eloquent {
	use SoftDeletingTrait;

	protected $dates = ['deleted_at'];
}

ソフトデリート操作のAPIは、今までと変わりありません。The API for all soft delete operations remains the same.

注意: SoftDeletingTraitは、ベースモデルで使用してはいけません。実際のモデルクラスで使用します。Note: The SoftDeletingTrait can not be applied on a base model. It must be used on an actual model class.

View/PaginationのEnvironmentクラスの名前変更View / Pagination Environment Renamed

もし、Illuminate\View\Environmentクラスか、Illuminate\Pagination\Environmentクラスを直接参照している場合、Illuminate\View\FactoryIlluminate\Pagination\Factoryを代わりに参照するように、コードを変更してください。この2つのクラスは、機能をより良く表すように名前が変更されました。If you are directly referencing the Illuminate\View\Environment class or Illuminate\Pagination\Environment class, update your code to reference Illuminate\View\Factory and Illuminate\Pagination\Factory instead. These two classes have been renamed to better reflect their function.

ペジネーションプレゼンテーターの引数追加Additional Parameter On Pagination Presenter

Illuminate\Pagination\Presenterクラスを拡張している場合、getPageLinkWrapper抽象メソッドに、rel引数を追加するように変更してください。If you are extending the Illuminate\Pagination\Presenter class, the abstract method getPageLinkWrapper signature has changed to add the rel argument:

abstract public function getPageLinkWrapper($url, $page, $rel = null);

Iron.Ioキューの暗号化Iron.Io Queue Encryption

Iron.ioキュードライバーを使用している場合、新しいencryptオプションをキュー設定ファイルに追加する必要があります。If you are using the Iron.io queue driver, you will need to add a new encrypt option to your queue configuration file:

'encrypt' => true

Upgrading To 4.1.29 From <= 4.1.xUpgrading To 4.1.29 From <= 4.1.x

Laravel4.1.29では、全データベースドライバーのカラムクオーティングが向上しました。Eloquentモデルにfillableを使用していない場合の、複数代入に関する脆弱性からアプリケーションを保護します。複数代入されるのを防ぐためにモデルにfillableプロパティを使用している場合には、アプリケーションに脆弱性はありません。しかし、guardedを使用し、ユーザーがコントロールできる配列を"update"や"save”タイプの機能に渡しているのでしたら、複数代入のリスクにアプリケーションがさらされているため、4.1.29へすぐアップグレードすべきでしょう。Laravel 4.1.29 improves the column quoting for all database drivers. This protects your application from some mass assignment vulnerabilities when not using the fillable property on models. If you are using the fillable property on your models to protect against mass assignment, your application is not vulnerable. However, if you are using guarded and are passing a user controlled array into an "update" or "save" type function, you should upgrade to 4.1.29 immediately as your application may be at risk of mass assignment.

Laravel4.1.29へアップグレードするには、composer updateを実行するだけです。このリリースには、ソース修正が必要な変更は含まれていません。To upgrade to Laravel 4.1.29, simply composer update. No breaking changes are introduced in this release.

4.1.25以下から、4.1.26へのアップグレードUpgrading To 4.1.26 From <= 4.1.25

Laravel 4.1.26では、"Remember me"クッキーへのセキュリティーが強化されました。このアップデート以前は、Remeberクッキーが悪意のあるユーザーによりハイジャックされ、本当のユーザーがアカウントのパスワードをリセットしたり、ログアウトしたりしても、クッキーが長期に渡り有効なままにされてしまいました。Laravel 4.1.26 introduces security improvements for "remember me" cookies. Before this update, if a remember cookie was hijacked by another malicious user, the cookie would remain valid for a long period of time, even after the true owner of the account reset their password, logged out, etc.

今回の変更により、usersテーブル(もしくはユーザー管理を行うためのテーブル)へ、新しいremember_tokenカラムを追加する必要があります。この変更により、ユーザーがアプリケーションにログインするたびに、真新しいトークンが割り当てられます。このトークンはユーザーがアプリケーションからログアウトするたびに、再生成されます。この実装により、もしも"Remember me"クッキがーハイジャックされても、アプリケーションからログアウトすれば、そのクッキーは無効になります。This change requires the addition of a new remember_token column to your users (or equivalent) database table. After this change, a fresh token will be assigned to the user each time they login to your application. The token will also be refreshed when the user logs out of the application. The implications of this change are: if a "remember me" cookie is hijacked, simply logging out of the application will invalidate the cookie.

アップデート法Upgrade Path

最初に、新しいremember_token(null値可能なVARCHAR(100)かTEXTなど)カラムをusersテーブルに追加してください。First, add a new, nullable remember_token of VARCHAR(100), TEXT, or equivalent to your users table.

次に、Eloquent認証ドライバーを使用しているのであれば、Userクラスへ以下の3クラスを追加してください。Next, if you are using the Eloquent authentication driver, update your User class with the following three methods:

public function getRememberToken()
{
	return $this->remember_token;
}

public function setRememberToken($value)
{
	$this->remember_token = $value;
}

public function getRememberTokenName()
{
	return 'remember_token';
}

**注意:**この変更により、現在使用中の"Remember me"セッションは無効となるため、全ユーザーはアプリケーションへの再認証を強制されます。Note: All existing "remember me" sessions will be invalidated by this change, so all users will be forced to re-authenticate with your application.

パッケージメンテナーの方へPackage Maintainers

Illuminate\Auth\UserProviderInterfaceへ、新しいメソッドが2つ追加されました。実装のサンプルは、デフォルトドライバーをご覧ください。Two new methods were added to the Illuminate\Auth\UserProviderInterface interface. Sample implementations may be found in the default drivers:

public function retrieveByToken($identifier, $token);

public function updateRememberToken(UserInterface $user, $token);

Illuminate\Auth\UserInterfaceにも、「アップデート法」で説明している、新しい3つのメソッドが追加されました。The Illuminate\Auth\UserInterface also received the three new methods described in the "Upgrade Path".

4.0から4.1へアップグレードUpgrading To 4.1 From 4.0

コンポーサー依存パッケージのアップグレードUpgrading Your Composer Dependency

アプリケーションをLaravel4.1へアップグレードするには、composer.jsonファイルの中のlaravel/frameworkのバージョンを4.1に変更します。To upgrade your application to Laravel 4.1, change your laravel/framework version to 4.1.* in your composer.json file.

ファイルの置き換えReplacing Files

public/index.phpファイルをこのリポジトリーの新バージョンへ置き換えて下さい。Replace your public/index.php file with this fresh copy from the repository[https://github.com/laravel/laravel/blob/master/public/index.php].

artisanファイルをこのリポジトリーの新バージョンへ置き換えて下さい。Replace your artisan file with this fresh copy from the repository[https://github.com/laravel/laravel/blob/master/artisan].

設定ファイルとオプションの追加Adding Configuration Files & Options

app/config/app.php設定ファイル中のaliasesproviders配列を更新します。変更する内容はこのファイルで確認して下さい。自分で追加したサービスプロバーダーとエイリアスを書き戻すのを忘れないで下さい。Update your aliases and providers arrays in your app/config/app.php configuration file. The updated values for these arrays can be found in this file[https://github.com/laravel/laravel/blob/master/app/config/app.php]. Be sure to add your custom and package service providers / aliases back to the arrays.

新規にapp/config/remote.phpファイルをこのリポジトリーから取得し、追加して下さい。Add the new app/config/remote.php file from the repository[https://github.com/laravel/laravel/blob/master/app/config/remote.php].

app/config/session.phpファイルへ新しいexpire_on_close設定オプションを追加して下さい。デフォルト値はfalseです。Add the new expire_on_close configuration option to your app/config/session.php file. The default value should be false.

app/config/queue.phpファイルへ新しいfailed設定セクションを追加して下さい。セクションのデフォルト値は以下の通りです。Add the new failed configuration section to your app/config/queue.php file. Here are the default values for the section:

'failed' => array(
	'database' => 'mysql', 'table' => 'failed_jobs',
),

(オプション):app/config/view.phpファイル中のpagination設定オプションをpagination::slider-3に変更することもできます。(Optional) Update the pagination configuration option in your app/config/view.php file to pagination::slider-3.

コントローラーの更新Controller Updates

もし、app/controllers/BaseController.phpが頭のところでuse文を使用していたら、use Illuminate\Routing\Controllers\Controller;use Illuminate\Routing\Controller;へ変更して下さい。If app/controllers/BaseController.php has a use statement at the top, change use Illuminate\Routing\Controllers\Controller; to use Illuminate\Routing\Controller;.

パスワードリマインダーの更新Password Reminders Updates

パスワードリマインダーは自由度を増すために全体的に見なおされました。php artisan auth:reminders-controller Artisanコマンドを実行し、作成される新しいスタブコントローラーを調べてみて下さい。もしくは、更新されたドキュメントを読み、それに従ってアプリケーションを更新して下さい。Password reminders have been overhauled for greater flexibility. You may examine the new stub controller by running the php artisan auth:reminders-controller Artisan command. You may also browse the updated documentation[/docs/security#password-reminders-and-reset] and update your application accordingly.

app/lang/en/reminders.php言語ファイルをこちらの更新済みファイルに合わせて変更して下さい。Update your app/lang/en/reminders.php language file to match this updated file[https://github.com/laravel/laravel/blob/master/app/lang/en/reminders.php].

環境決定の更新Environment Detection Updates

セキュリティーの観点から、アプリケーションの環境を決定するためにURLのドメインはもう使用されなくなりました。これらの値は簡単に偽装でき、リクエストの環境を変更する攻撃が可能です。コンピューターのホスト名を利用するように、環境決定コードを変更して下さい。(hostnameコマンドがMac、Linux、Windowsで使用できます。)For security reasons, URL domains may no longer be used to detect your application environment. These values are easily spoofable and allow attackers to modify the environment for a request. You should convert your environment detection to use machine host names (hostname command on Mac, Linux, and Windows).

ログファイルの単純化Simpler Log Files

今回よりLaravelは、app/storage/logs/laravel.logファイルのみを作成、使用するようになりました。しかし、この動作はapp/start/global.phpファイルで設定できるままになっています。Laravel now generates a single log file: app/storage/logs/laravel.log. However, you may still configure this behavior in your app/start/global.php file.

Trailing Slashリダイレクトの削除Removing Redirect Trailing Slash

bootstrap/start.phpファイルの中から、$app->redirectIfTrailingSlash()'の呼び出しを削除して下さい。この機能はフレームワークに含まれている.htaccess`ファイルで処理されるようになったため、メソッドは必要なくなりました。In your bootstrap/start.php file, remove the call to $app->redirectIfTrailingSlash(). This method is no longer needed as this functionality is now handled by the .htaccess file included with the framework.

次に、public/.htaccessファイルを最後のスラッシュを処理する新バージョンへ置き換えて下さい。Next, replace your Apache .htaccess file with this new one[https://github.com/laravel/laravel/blob/master/public/.htaccess] that handles trailing slashes.

現在のルートへのアクセスCurrent Route Access

現在のルートへアクセスするには、Route::getCurrentRoute()の代わりに、Route::current()が使えるようになりました。The current route is now accessed via Route::current() instead of Route::getCurrentRoute().

Composerの更新Composer Update

以上の変更を行ったら、アプリケーションのコアファイルを更新するために、composer updateを実行して下さい!クラスのロードエラーになった場合は、updateコマンドを--no-scriptsオプションを付け、実行してみてください。ですから、composer update --no-scriptsと実行します。Once you have completed the changes above, you can run the composer update function to update your core application files! If you receive class load errors, try running the update command with the --no-scripts option enabled like so: composer update --no-scripts.

ワイルドカードイベントリスナーWildcard Event Listeners

ワイルドカードイベントリスナーは、ハンドラー関数の引数にイベントを渡さなくなりました。発行されたイベントを見つける必要がある場合は、Event::firing()を使用してください。The wildcard event listeners no longer append the event to your handler functions parameters. If you require finding the event that was fired you should use Event::firing().

章選択

Artisan CLI

設定

明暗テーマ
light_mode
dark_mode
brightness_auto システム設定に合わせる
テーマ選択
photo_size_select_actual デフォルト
photo_size_select_actual モノクローム(白黒)
photo_size_select_actual Solarized風
photo_size_select_actual GitHub風(青ベース)
photo_size_select_actual Viva(黄緑ベース)
photo_size_select_actual Happy(紫ベース)
photo_size_select_actual Mint(緑ベース)
コードハイライトテーマ選択

明暗テーマごとに、コードハイライトのテーマを指定できます。

テーマ配色確認
スクリーン表示幅
640px
80%
90%
100%

768px以上の幅があるときのドキュメント部分表示幅です。

インデント
無し
1rem
2rem
3rem
原文確認
原文を全行表示
原文を一行ずつ表示
使用しない

※ 段落末のEボタンへカーソルオンで原文をPopupします。

Diff表示形式
色分けのみで区別
行頭の±で区別
削除線と追記で区別

※ [tl!…]形式の挿入削除行の表示形式です。

テストコード表示
両コード表示
Pestのみ表示
PHPUnitのみ表示
和文変換

対象文字列と置換文字列を半角スペースで区切ってください。(最大5組各10文字まで)

本文フォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

コードフォント

総称名以外はCSSと同様に、"〜"でエスケープしてください。

保存内容リセット

localStrageに保存してある設定項目をすべて削除し、デフォルト状態へ戻します。

ヘッダー項目移動

キーボード操作