Readouble

Laravel 5.1 リリースノート

サポートポリシーSupport Policy

Laravel5.1のようなLTSリリースでは、バグフィックスは2年間、セキュリティフィックスは3年間提供します。これらのリリースは長期間に渡るサポートとメンテナンスを提供します。For LTS releases, such as Laravel 5.1, bug fixes are provided for 2 years and security fixes are provided for 3 years. These releases provide the longest window of support and maintenance.

一般的なリリースでは、バグフィックスは6ヶ月、セキュリティフィックスは1年です。For general releases, bug fixes are provided for 6 months and security fixes are provided for 1 year.

Laravel 5.1.11Laravel 5.1.11

Laravel 5.1.11では認可が初めからサポートされています! アプリケーションの認可ロジックをシンプルなコールバックかポリシークラスを使い便利に統合でき、アクションをシンプルで記述的なメソッドを使い認可できます。Laravel 5.1.11 introduces authorization[/docs/{{version}}/authorization] support out of the box! Conveniently organize your application's authorization logic using simple callbacks or policy classes, and authorize actions using simple, expressive methods.

詳細は[認可のドキュメント]authorization documentationを参照してください。For more information, please refer to the authorization documentation[/docs/{{version}}/authorization].

Laravel 5.1.4Laravel 5.1.4

Laravel5.1.4でシンプルなログイン制限がフレームワークに導入されました。詳細は認証のドキュメントで確認してください。Laravel 5.1.4 introduces simple login throttling to the framework. Consult the authentication documentation[/docs/{{version}}/authentication#authentication-throttling] for more information.

Laravel 5.1Laravel 5.1

Laravel5.1はPSR-2を採用し、イベントのブロードキャスト、ミドルウェアパラメーター、Artisanの改良など、Laravel5.0から継続的に向上しています。Laravel 5.1 continues the improvements made in Laravel 5.0 by adopting PSR-2 and adding event broadcasting, middleware parameters, Artisan improvements, and more.

PHP 5.5.9 PHP 5.5.9

PHP5.4は9月に「役目を終える」ことになり、PHP開発チームからセキュリティアップデートを受けられなくなりますので、Laravel5.1はPHP5.5.9以上を動作要件とします。PHP5.5.9はGuzzleやAWS SDKのように人気のあるPHPライブラリーの最新バージョンと互換性があります。Since PHP 5.4 will enter "end of life" in September and will no longer receive security updates from the PHP development team, Laravel 5.1 requires PHP 5.5.9 or greater. PHP 5.5.9 allows compatibility with the latest versions of popular PHP libraries such as Guzzle and the AWS SDK.

LTSLTS

Laravel5.1は最初の長期間サポートリリースになります。Laravel5.1はバグフィックスを2年間、セキュリティフィックスを3年間提供します。このサポート期間は今までのリリースで一番長く、安定性と心の平和を大きなエンタープライズの顧客に提供します。Laravel 5.1 is the first release of Laravel to receive long term support. Laravel 5.1 will receive bug fixes for 2 years and security fixes for 3 years. This support window is the largest ever provided for Laravel and provides stability and peace of mind for larger, enterprise clients and customers.

PSR-2PSR-2

PSR-2コーディングスタイルガイドがLaravelフレームワークの標準スタイルガイドとして採用されました。さらに全ジェネレーターがPSR-2と互換性のある記法を生成するように更新されました。The PSR-2 coding style guide[https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md] has been adopted as the default style guide for the Laravel framework. Additionally, all generators have been updated to generate PSR-2 compatible syntax.

ドキュメントDocumentation

Laravelのドキュメントの全ページは注意深く見直され、大きく向上しました。全サンプルコードはレビューされ、より適切でコンテキストに合うように更新されました。Every page of the Laravel documentation has been meticulously reviewed and dramatically improved. All code examples have also been reviewed and expanded to provide more relevance and context.

イベントブロードキャストEvent Broadcasting

近代的なWebアプリケーションでは、リアルタイムですぐに更新されるユーザーインターフェイスを実装するために、Webソケットが使用されています。あるデータがサーバーで更新されると、そのメッセージはWebソケット接続を通じ、クライアントで処理されるように送信されます。In many modern web applications, web sockets are used to implement real-time, live-updating user interfaces. When some data is updated on the server, a message is typically sent over a websocket connection to be handled by the client.

こうしたタイプのアプリケーションを構築する手助けになるように、LaravelはイベントをWebソケット接続上へ簡単に「ブロードキャスト」できるようにしました。Laravelイベントをブロードキャストすることにより、同じイベント名をサーバーサイドのコードとクライアントサイドのJavaScriptフレームワークとで共有できるようになります。To assist you in building these types of applications, Laravel makes it easy to "broadcast" your events over a websocket connection. Broadcasting your Laravel events allows you to share the same event names between your server-side code and your client-side JavaScript framework.

イベントのブロードキャストをより詳しく知るには、イベントのドキュメントを読んでください。To learn more about event broadcasting, check out the event documentation[/docs/{{version}}/events#broadcasting-events].

ミドルウェアパラメーターMiddleware Parameters

ミドルウェアは追加のカスタムパラメーターを受け取れるようになりました。たとえば、指定されたアクションを取る前に、指定された「役割(role)」を認証済みユーザーが持っているかをアプリケーションで確認する必要があるとします。役割名を追加の引数として受け取るRoleMiddlewareを作成することができます。Middleware can now receive additional custom parameters. For example, if your application needs to verify that the authenticated user has a given "role" before performing a given action, you could create a RoleMiddleware that receives a role name as an additional argument:

<?php

namespace App\Http\Middleware;

use Closure;

class RoleMiddleware
{
    /**
     * Run the request filter.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string  $role
     * @return mixed
     */
    public function handle($request, Closure $next, $role)
    {
        if (! $request->user()->hasRole($role)) {
            // Redirect...
        }

        return $next($request);
    }

}

ミドルウエアパラメーターはルートを定義するときに指定され、ミドルウェア名とパラメーターを:で区切ります。複数のパラメーターはカンマで区切ります。Middleware parameters may be specified when defining the route by separating the middleware name and parameters with a :. Multiple parameters should be delimited by commas:

Route::put('post/{id}', ['middleware' => 'role:editor', function ($id) {
    //
}]);

ミドルウェアについての詳細については、ミドルウェアのドキュメントを調べてください。For more information on middleware, check out the middleware documentation[/docs/{{version}}/middleware].

テストのオーバーオールTesting Overhaul

Laravelの組み込みテスト機構は大幅に向上しました。アプリケーションと関連し、レスポンスを調べるためのスラスラと記述しやすいインターフェイスの新しいメソッドが数多く提供されました。以下のテストを見てください。The built-in testing capabilities of Laravel have been dramatically improved. A variety of new methods provide a fluent, expressive interface for interacting with your application and examining its responses. For example, check out the following test:

public function testNewUserRegistration()
{
    $this->visit('/register')
         ->type('Taylor', 'name')
         ->check('terms')
         ->press('Register')
         ->seePageIs('/dashboard');
}

テストの詳細は、テストのドキュメントを確認してください。For more information on testing, check out the testing documentation[/docs/{{version}}/testing].

モデルファクトリーModel Factories

モデルファクトリーを使い、Eloquentモデルのスタブを簡単に作成する方法が提供されました。モデルファクトリーによりEloquentモデルの「デフォルト」属性を定義し、テストやデータベースシーディング(初期値設定)に利用するモデルインスタンスを簡単に生成できます。また、ランダムな属性データーを生成するためのFaker PHPライブラリーの強力な機能をモデルファクトリーで使えます。Laravel now ships with an easy way to create stub Eloquent models using model factories[/docs/{{version}}/testing#model-factories]. Model factories allow you to easily define a set of "default" attributes for your Eloquent model, and then generate test model instances for your tests or database seeds. Model factories also take advantage of the powerful Faker[https://github.com/fzaninotto/Faker] PHP library for generating random attribute data:

$factory->define(App\User::class, function ($faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->email,
        'password' => str_random(10),
        'remember_token' => str_random(10),
    ];
});

モデルファクトリーの詳細は、ドキュメントを参照してください。For more information on model factories, check out the documentation[/docs/{{version}}/testing#model-factories].

Artisanの向上Artisan Improvements

Artisanコマンドは、コマンドラインの引数とオプションを定義するための、とても簡単なインターフェイスを提供するルート定義のような「使い方」で指定できるようになりました。たとえば、シンプルなコマンドとオプションを定義してみましょう。Artisan commands may now be defined using a simple, route-like "signature", which provides an extremely simple interface for defining command line arguments and options. For example, you may define a simple command and its options like so:

/**
 * コンソールコマンドの名前と使用法
 *
 * @var string
 */
protected $signature = 'email:send {user} {--force}';

Artisanコマンドの定義の詳細は、Artisanのドキュメントを読んでください。For more information on defining Artisan commands, consult the Artisan documentation[/docs/{{version}}/artisan].

フォルダー構造Folder Structure

より意図が分かりやすいように、app/Commandsディレクトリーはapp/Jobsに名前が変更されました。さらに、app/Handlersディレクトリーは、イベントリスナー専用のapp/Listenersに統合されました。しかしこれは互換性を崩す変更ではなく、Laravel5.1の新しいフォルダー構造へ更新する必要はありません。To better express intent, the app/Commands directory has been renamed to app/Jobs. Additionally, the app/Handlers directory has been consolidated into a single app/Listeners directory which simply contains event listeners. However, this is not a breaking change and you are not required to update to the new folder structure to use Laravel 5.1.

暗号化Encryption

以前のバージョンのLaravelはPHPのmcrypt拡張により暗号化が行われていました。Laravel5.1からは、より活発にメンテナンスが行われているopenssl拡張により暗号化が処理されます。In previous versions of Laravel, encryption was handled by the mcrypt PHP extension. However, beginning in Laravel 5.1, encryption is handled by the openssl extension, which is more actively maintained.

Laravel 5.0Laravel 5.0

Laravel5.0では、Laravelプロジェクトに対する全く新しいアプリケーション構造が、デフォルトとして導入されました。この新構造は、Laravelで堅牢なアプリケーションを構築するためより良い基礎となり、同時にアプリケーション全体へ新しいオートローディング規約(PSR-4)を適用します。最初に、大きな変更点を確認しましょう。Laravel 5.0 introduces a fresh application structure to the default Laravel project. This new structure serves as a better foundation for building a robust application in Laravel, as well as embraces new auto-loading standards (PSR-4) throughout the application. First, let's examine some of the major changes:

新フォルダー構造New Folder Structure

古いapp/modelsディレクトリーは完全に取り除かれました。代わりに、皆さんの全コードは直接appフォルダーの中に記述し、デフォルトではApp名前空間として統合されます。このデフォルト名前空間は、app:name Artisanコマンドを使い、簡単に変更できます。The old app/models directory has been entirely removed. Instead, all of your code lives directly within the app folder, and, by default, is organized to the App namespace. This default namespace can be quickly changed using the new app:name Artisan command.

コントローラー、ミドルウェア、リクエスト(Laravel5.0の新しいクラスタイプ)は、アプリケーションのHTTPトランスポート層と関連するクラスとして、app/Httpディレクトリ下に全部まとめられます。構造を持たない一つのルートフィルターファイルの代わりに、全ミドルウェアーは、それぞれのクラスファイルへ分割されました。Controllers, middleware, and requests (a new type of class in Laravel 5.0) are now grouped under the app/Http directory, as they are all classes related to the HTTP transport layer of your application. Instead of a single, flat file of route filters, all middleware are now broken into their own class files.

新しいapp/Providersディレクトリーが、以前のLaravel4.xで使われていたapp/startファイルに置き換わりました。これらのサービスプロバイダーは、エラーハンドリング、ロギング、ルートのロードなど、アプリケーションの様々な機能の初期準備を担います。もちろん、自分のアプリケーションのために、追加のサービスプロバイダーを自由に作成できます。A new app/Providers directory replaces the app/start files from previous versions of Laravel 4.x. These service providers provide various bootstrapping functions to your application, such as error handling, logging, route loading, and more. Of course, you are free to create additional service providers for your application.

アプリケーションの言語ファイルとビューは、resourcesディレクトリーへ移動しました。Application language files and views have been moved to the resources directory.

契約Contracts

Laravelの主要なコンポーネント全ての実装インターフェイスが、illuminate/contractsリポジトリーの中に設置されてました。このリポジトリーは外部依存していません。分離性と依存注入のため、使用しているインターフェイスが一箇所にまとまっている利点により、Laravelファサードへ別の選択肢を簡単に導入できるでしょう。All major Laravel components implement interfaces which are located in the illuminate/contracts repository. This repository has no external dependencies. Having a convenient, centrally located set of interfaces you may use for decoupling and dependency injection will serve as an easy alternative option to Laravel Facades.

契約の詳細は、ドキュメントに全て記載されています。For more information on contracts, consult the full documentation[/docs/{{version}}/contracts].

ルートキャッシュRoute Cache

アプリケーションが全てコントローラールートにより構築されている場合、ルート登録の速度をドラマティックに早く改善するため、新しいroute:cache Artisanコマンドを活用できます。これは、主にアプリケーションが100以上のルートを持っている場合に役立ち、アプリケーションのルート登録を劇的にスピードアップします。If your application is made up entirely of controller routes, you may utilize the new route:cache Artisan command to drastically speed up the registration of your routes. This is primarily useful on applications with 100 routes and will drastically speed up this portion of your application.

ルートミドルウェアRoute Middleware

Laravel4スタイルのルート「フィルター」に付け加え、Laravel5ではHTTPミドルウェアもサポートしています。認証やCSRF「フィルター」はミドルウェアに変更されました。ミドルウェアはリクエストがアプリケーションに完全に届く前に検査や、拒否さえも簡単にできるように、全タイプのフィルターを置き換えられる一つの首尾一貫したインターフェイスを提供します。In addition to Laravel 4 style route "filters", Laravel 5 now supports HTTP middleware, and the included authentication and CSRF "filters" have been converted to middleware. Middleware provides a single, consistent interface to replace all types of filters, allowing you to easily inspect, and even reject, requests before they enter your application.

ミドルウェアの詳細は、ドキュメントで確認してください。For more information on middleware, check out the documentation[/docs/{{version}}/middleware].

コントローラーメソッドインジェクションController Method Injection

既存のコンストラクターインジェクションに付け加え、今度はコントローラーメソッドでもタイプヒントによる依存指定ができるようになりました。ルートメソッドに別の引数が存在していても、サービスコンテナが自動的に依存を注入します。In addition to the existing constructor injection, you may now type-hint dependencies on controller methods. The service container[/docs/{{version}}/container] will automatically inject the dependencies, even if the route contains other parameters:

public function createPost(Request $request, PostRepository $posts)
{
    //
}

認証のスカフォールドAuthentication Scaffolding

ユーザー登録、認証、パスワードリセットコントローラーは、最初から準備されています。同時に対応するビューも、resources/views/authに用意されます。さらに、"users"テーブルのマイグレーションも含まれています。簡単なリソースが用意されていることにより、認証の定形コードに手間取ること無く、アプリケーションのアイデアを素早く開発できるようになります。認証ビューへアクセスするルートは、auth/loginauth/registerです。App\Services\Auth\Registrarサービスは、ユーザーバリデーションと作成に責任を持っています。User registration, authentication, and password reset controllers are now included out of the box, as well as simple corresponding views, which are located at resources/views/auth. In addition, a "users" table migration has been included with the framework. Including these simple resources allows rapid development of application ideas without bogging down on authentication boilerplate. The authentication views may be accessed on the auth/login and auth/register routes. The App\Services\Auth\Registrar service is responsible for user validation and creation.

イベントオブジェクトEvent Objects

イベントは単なる文字列の代わりに、オブジェクトとして定義されます。以下のイベント例で確認してください。You may now define events as objects instead of simply using strings. For example, check out the following event:

<?php

class PodcastWasPurchased
{
    public $podcast;

    public function __construct(Podcast $podcast)
    {
        $this->podcast = $podcast;
    }
}

イベントは普通にディスパッチできます。The event may be dispatched like normal:

Event::fire(new PodcastWasPurchased($podcast));

もちろん、イベントハンドラーは、データのリストの代わりに、イベントオブジェクトを受け取ります。Of course, your event handler will receive the event object instead of a list of data:

<?php

class ReportPodcastPurchase
{
    public function handle(PodcastWasPurchased $event)
    {
        //
    }
}

イベント関連の詳細情報は、ドキュメントで完全に記載されています。For more information on working with events, check out the full documentation[/docs/{{version}}/events].

コマンド/キューイングCommands / Queueing

Laravel4でサポートしているキュージョブの形式に付け加え、Laravel5ではキューするジョブをシンプルなコマンドオブジェクトとして表すことができるようになりました。これらのコマンドは、app/Commandsディレクトリーに設置します。サンプルコマンドをご覧ください。In addition to the queue job format supported in Laravel 4, Laravel 5 allows you to represent your queued jobs as simple command objects. These commands live in the app/Commands directory. Here's a sample command:

<?php

class PurchasePodcast extends Command implements SelfHandling, ShouldBeQueued
{
    use SerializesModels;

    protected $user, $podcast;

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(User $user, Podcast $podcast)
    {
        $this->user = $user;
        $this->podcast = $podcast;
    }

    /**
     * Execute the command.
     *
     * @return void
     */
    public function handle()
    {
        // Handle the logic to purchase the podcast...

        event(new PodcastWasPurchased($this->user, $this->podcast));
    }
}

コマンドを簡単に実行できるように、ベースLaravelコントローラーで、DispatchesCommandsトレイトが使用されています。The base Laravel controller utilizes the new DispatchesCommands trait, allowing you to easily dispatch your commands for execution:

$this->dispatch(new PurchasePodcastCommand($user, $podcast));

もちろん、(キューに入れず)タスクを同期的に実行するコマンドを使用することもできます。実際、アプリケーションで実行する必要のある複雑なタスクをカプセル化するため、コマンドは良い手段です。詳細は、コマンドバスのドキュメントで確認してください。Of course, you may also use commands for tasks that are executed synchronously (are not queued). In fact, using commands is a great way to encapsulate complex tasks your application needs to perform. For more information, check out the command bus[/docs/{{version}}/bus] documentation.

データベースキューDatabase Queue

databaseキュードライバーがLaravelに追加されました。データベースソフトウェアの他、余計な追加パッケージが必要がない、シンプルなローカルのキュードライバーです。A database queue driver is now included in Laravel, providing a simple, local queue driver that requires no extra package installation beyond your database software.

LaravelスケジューラーLaravel Scheduler

これまで開発者は、時間で実行したいコンソールコマンドに対し、一つ一つCronエントリーを作成してきました。しかし、これは面倒でした。コンソールスケジューラーはソースコントロールされておらず、Cronエントリを追加するためにSSHでサーバーに接続する必要がありました。人生をより簡単にしましょう。LaravelコマンドスケジューラーはLaravel自身の中でコマンドスケジュールがスラスラと記述的に定義できるようにしてくれ、サーバーに必要なCronエントリはたったひとつだけです。In the past, developers have generated a Cron entry for each console command they wished to schedule. However, this is a headache. Your console schedule is no longer in source control, and you must SSH into your server to add the Cron entries. Let's make our lives easier. The Laravel command scheduler allows you to fluently and expressively define your command schedule within Laravel itself, and only a single Cron entry is needed on your server.

以下のような定義します。It looks like this:

$schedule->command('artisan:command')->dailyAt('15:00');

もちろん、スケジューラーの全てを学習したい場合は、ドキュメントを確認してください。Of course, check out the full documentation[/docs/{{version}}/scheduling] to learn all about the scheduler!

Tinker/PsyshTinker / Psysh

php artisan tinkerコマンドは、より堅牢なPHP REPLであるJustin Hileman作成のPsyshを使用するようになりました。Laravel4のBorisがお気に入りなら、Psyshはもっと好みでしょう。より良いことに、Windowsでも動作します!php artisan tinkerで試し始めてください。The php artisan tinker command now utilizes Psysh[https://github.com/bobthecow/psysh] by Justin Hileman, a more robust REPL for PHP. If you liked Boris in Laravel 4, you're going to love Psysh. Even better, it works on Windows! To get started, just try:

php artisan tinker

DotEnvDotEnv

環境設定ディレクトリーがネストし、色々と混乱させる代わりに、Laravel5ではVance Lucas制作のDotEnvを使用しています。このライブラリーは環境設定を管理するとても単純な手法を提供しており、Laravel5での環境決定は簡単です。詳細は、設定のドキュメントをご覧ください。Instead of a variety of confusing, nested environment configuration directories, Laravel 5 now utilizes DotEnv[https://github.com/vlucas/phpdotenv] by Vance Lucas. This library provides a super simple way to manage your environment configuration, and makes environment detection in Laravel 5 a breeze. For more details, check out the full configuration documentation[/docs/{{version}}/installation#environment-configuration].

Laravel ElixirLaravel Elixir

Laravel ElixirはJeffrey Wayにより開発された、アセットをコンパイルしたり、結合したりするためにスラスラと表現できるインターフェイスを提供しています。もしもGruntやGulpの学習が恐ろしくても、怖がる必要はありません。ElixirはLessやSass、CoffeeScriptをコンパイルするために、Gulpを簡単に使い始めさせてくれます。さらにテストまで実行してくれます!Laravel Elixir, by Jeffrey Way, provides a fluent, expressive interface to compiling and concatenating your assets. If you've ever been intimidated by learning Grunt or Gulp, fear no more. Elixir makes it a cinch to get started using Gulp to compile your Less, Sass, and CoffeeScript. It can even run your tests for you!

Elixirの詳細は、ドキュメントで確認してください。For more information on Elixir, check out the full documentation[/docs/{{version}}/elixir].

Laravel SocialiteLaravel Socialite

Laravel SocialiteはLaravel5.0コンパチブルのオプションパッケージで、OAuthプロバイダーによる認証を全く苦労無しで行えます。現在、Socialiteがサポートしているのは、Facebook、Twitter、Google、GitHubです。以下の例をご覧ください。Laravel Socialite is an optional, Laravel 5.0 compatible package that provides totally painless authentication with OAuth providers. Currently, Socialite supports Facebook, Twitter, Google, and GitHub. Here's what it looks like:

public function redirectForAuth()
{
    return Socialize::with('twitter')->redirect();
}

public function getUserFromProvider()
{
    $user = Socialize::with('twitter')->user();
}

OAuth認証のフローを書くために、時間を費やす必要はもうありません。数分で使用開始できます!ドキュメントで詳細が全部説明されています。No more spending hours writing OAuth authentication flows. Get started in minutes! The full documentation[/docs/{{version}}/authentication#social-authentication] has all the details.

Flysystemの統合Flysystem Integration

Laravelは強力なFlysystem抽象ファイルシステムライブラリーを採用しました。これにより、統一されたエレガントなAPI一つで、ローカルストレージ、Amazon S3、Rackクラウドストレージを苦労なしに統合できます。Laravel now includes the powerful Flysystem[https://github.com/thephpleague/flysystem] filesystem abstraction library, providing pain free integration with local, Amazon S3, and Rackspace cloud storage - all with one, unified and elegant API! Storing a file in Amazon S3 is now as simple as:

Storage::put('file.txt', 'contents');

LaravelとFlysystemの統合についての詳細は、ドキュメントをご覧ください。For more information on the Laravel Flysystem integration, consult the full documentation[/docs/{{version}}/filesystem].

フォームリクエストForm Requests

Laravel5.0は、Illuminate\Foundation\Http\FormRequestを拡張したクラスである、フォームリクエストを導入しました。このリクエストオブジェクトは、コントローラーメソッドインジェクションにより注入され、定形処理コードを書かなくとも、ユーザー入力のバリデーションが行えます。FormRequestのサンプルを掘り下げ確認してみましょう。Laravel 5.0 introduces form requests, which extend the Illuminate\Foundation\Http\FormRequest class. These request objects can be combined with controller method injection to provide a boiler-plate free method of validating user input. Let's dig in and look at a sample FormRequest:

<?php

namespace App\Http\Requests;

class RegisterRequest extends FormRequest
{
    public function rules()
    {
        return [
            'email' => 'required|email|unique:users',
            'password' => 'required|confirmed|min:8',
        ];
    }

    public function authorize()
    {
        return true;
    }
}

クラスが定義できれば、コントローラーアクションでタイプヒントを指定できます。Once the class has been defined, we can type-hint it on our controller action:

public function register(RegisterRequest $request)
{
    var_dump($request->input());
}

Laravel サービスコンテナがFormRequestインスタンスの注入を認識すると、そのリクエストは自動的にバリデーションが行われます。つまり、コントローラーのアクションが呼び出された時には、そのフォームリクエストクラスに指定したルールに従い、HTTPリクエストは入力のバリデーションに通され確認済みであると、安心して想定できます。さらに、リクエストがバリデーションに引っかかった場合、HTTPリダイレクトが自動的に行われ(カスタマイズ可能)、エラーメッセージもセッションにフラッシュデーターとして保存されるか、JSONに変換されます。 フォームバリデーションはこれまでないくらいにシンプルになりました。 FormRequestバリデーションの詳細は、ドキュメントをご覧ください。When the Laravel service container identifies that the class it is injecting is a FormRequest instance, the request will automatically be validated. This means that if your controller action is called, you can safely assume the HTTP request input has been validated according to the rules you specified in your form request class. Even more, if the request is invalid, an HTTP redirect, which you may customize, will automatically be issued, and the error messages will be either flashed to the session or converted to JSON. Form validation has never been more simple. For more information on FormRequest validation, check out the documentation[/docs/{{version}}/validation#form-request-validation].

シンプルなコントローラーリクエストバリデーションSimple Controller Request Validation

Laravel5のベースコントローラーは、ValidatesRequestsトレイトを取り込んでいます。このトレイトは、やってきたリクエストを手間なくバリデートする、validateメソッドを提供しています。もし、FormRequestがあなたのアプリケーションでは、多少大げさすぎるならば、これを使ってみてください。The Laravel 5 base controller now includes a ValidatesRequests trait. This trait provides a simple validate method to validate incoming requests. If FormRequests are a little too much for your application, check this out:

public function createPost(Request $request)
{
    $this->validate($request, [
        'title' => 'required|max:255',
        'body' => 'required',
    ]);
}

バリデーションが失敗すると、例外が投げられ、適切なHTTPレスポンスが自動的にブラウザへ送り返されます。バリデーションエラーもフラッシュデータとしてセッションに保存されます!AJAXリクエストの場合、Laravelはバリデーションエラーを表すJSONを送り返す面倒も見ます。If the validation fails, an exception will be thrown and the proper HTTP response will automatically be sent back to the browser. The validation errors will even be flashed to the session! If the request was an AJAX request, Laravel even takes care of sending a JSON representation of the validation errors back to you.

この新しいメソッドの詳細は、ドキュメントをご覧ください。For more information on this new method, check out the documentation[/docs/{{version}}/validation#validation-quickstart].

新ジェネレーターNew Generators

新しいデフォルトアプリケーション構造を手助けするため、Artisan生成コマンドが新しくフレームワークに追加されました。詳細は、php artisan listで確認してください。To complement the new default application structure, new Artisan generator commands have been added to the framework. See php artisan list for more details.

設定のキャッシュConfiguration Cache

config:cacheコマンドを使用して、全設定ファイルを一つのファイルへキャッシュできるようになりました。You may now cache all of your configuration in a single file using the config:cache command.

Symfony VarDumperSymfony VarDumper

変数をデバッグ情報としてダンプする、人気のddヘルパ関数が、素晴らしいSymfony VarDumperを使用するようにアップグレードされました。これは出力を色分けし、配列を折りたたむこともできます。プロジェクトで以下のように使用してください。The popular dd helper function, which dumps variable debug information, has been upgraded to use the amazing Symfony VarDumper. This provides color-coded output and even collapsing of arrays. Just try the following in your project:

dd([1, 2, 3]);

Laravel 4.2Laravel 4.2

このリリースの完全な変更リストは、4.2をインストールし、php artisan changesコマンドを実行するか、GitHubで変更を確認してください。このセクションの記述は、リリースの主要な向上点と変更だけを示しています。The full change list for this release by running the php artisan changes command from a 4.2 installation, or by viewing the change file on Github[https://github.com/laravel/framework/blob/4.2/src/Illuminate/Foundation/changes.json]. These notes only cover the major enhancements and changes for the release.

注意: 4.2のリリースまでの間に、多くの様々な小さなバグ修正や改善が、Laravel4.1に取り込まれてきました。ですから、Laravel4.1の変更リストも注意深くチェックしてください。Note: During the 4.2 release cycle, many small bug fixes and enhancements were incorporated into the various Laravel 4.1 point releases. So, be sure to check the change list for Laravel 4.1 as well!

PHP 5.4が必要PHP 5.4 Requirement

Laravel4.2を動作させるには、PHP5.4以上が必要です。このPHPに関する動作要件の引き上げにより、Laravelキャッシャーなどのツールで、より記述的なインターフェイスを提供するための、トレイトのような新しい機能を使用することができるようになりました。更に、PHP5.4はPHP5.3よりも、大きな速度と効率の向上をもたらしてくれます。Laravel 4.2 requires PHP 5.4 or greater. This upgraded PHP requirement allows us to use new PHP features such as traits to provide more expressive interfaces for tools like Laravel Cashier[/docs/billing]. PHP 5.4 also brings significant speed and performance improvements over PHP 5.3.

Laravel ForgeLaravel Forge

Laravel Forgeは、新しいWebベースアプリケーションで、皆さんが選んだLinode、DigitalOcean、Rackspace、Amazon EC2のようなクラウド上で、PHPサービスを作成し管理する、シンプルな方法を提供しています。自動的なNginx設定、SSHキーアクセス、cronジョブの自動化、NewRelicとPapertrailによるサーバー監視、「Pushによるデプロイ」、Laravelキュー・ワーカー設定などをサポートしています。Forgeは皆さんのLaravelアプリケーション全部をランチする、最もシンプルで、手に入れやすい手法です。Laravel Forge, a new web based application, provides a simple way to create and manage PHP servers on the cloud of your choice, including Linode, DigitalOcean, Rackspace, and Amazon EC2. Supporting automated Nginx configuration, SSH key access, Cron job automation, server monitoring via NewRelic & Papertrail, "Push To Deploy", Laravel queue worker configuration, and more, Forge provides the simplest and most affordable way to launch all of your Laravel applications.

インストールしたLaravel4.2の中の、app/config/database.php設定ファイルが、デフォルトでForge使用の設定ファイルになり、プラットフォームへ真新しいアプリケーションを便利にデプロイできるようにしてくれます。The default Laravel 4.2 installation's app/config/database.php configuration file is now configured for Forge usage by default, allowing for more convenient deployment of fresh applications onto the platform.

Laravel Forgeの詳細な情報は、Forgeの公式Webサイトをご覧ください。More information about Laravel Forge can be found on the official Forge website[https://forge.laravel.com].

Laravel HomesteadLaravel Homestead

Laravel Homesteadは、強固なLaravelとPHPアプリケーションをデプロイするための、公式Vagrant環境です。配布のためにboxをバッケージする前に、広大な範囲に渡る、必要なboxの準備作業は処理済みですから、非常に素早くboxを起動可能です。Homesteadは、Nginx1.6、PHP5.6、MySQL、Postgres、Redis、Memcached、Beanstalk、Node、Gulp、Grunt、Bowerを用意しています。HomesteadはシンプルなHomestead.yaml設定ファイルを含んでおり、複数のLaravelアプリケーションを一つのboxで管理しています。Laravel Homestead is an official Vagrant environment for developing robust Laravel and PHP applications. The vast majority of the boxes' provisioning needs are handled before the box is packaged for distribution, allowing the box to boot extremely quickly. Homestead includes Nginx 1.6, PHP 5.6, MySQL, Postgres, Redis, Memcached, Beanstalk, Node, Gulp, Grunt, & Bower. Homestead includes a simple Homestead.yaml configuration file for managing multiple Laravel applications on a single box.

インストールしたLaravel4.2に含まれており、初めから用意されているHomesteadデータベースを使用するために設定されている、app/config/local/database.php設定ファイルは、Laravelの初期インストールと設定をより便利にしています。The default Laravel 4.2 installation now includes an app/config/local/database.php configuration file that is configured to use the Homestead database out of the box, making Laravel initial installation and configuration more convenient.

公式ドキュメントにも、Homesteadのドキュメントが追加されました。The official documentation has also been updated to include Homestead documentation[/docs/homestead].

LaravelキャッシャーLaravel Cashier

Laravelキャッシャーは、Stripeを使用し、購読の課金を管理するための、シンプルで記述的なライブラリーです。Laravel4.2で紹介し、キャッシャーのドキュメントも、Laravelのメインドキュメントに含めましたが、コンポーネントのインストールはまだオプションです。このリリースのキャッシャーは、多くのバグが修正され、複数通貨をサポートし、最新のStripe APIとコンパチブルです。Laravel Cashier is a simple, expressive library for managing subscription billing with Stripe. With the introduction of Laravel 4.2, we are including Cashier documentation along with the main Laravel documentation, though installation of the component itself is still optional. This release of Cashier brings numerous bug fixes, multi-currency support, and compatibility with the latest Stripe API.

デーモン・キュー・ワーカーDaemon Queue Workers

Artisanのqueue:workコマンドは、--daemonオプションをサポートし、ワーカーを「デーモンモード」で開始できます。つまり、ワーカーはフレームワークを再起動することなく、ジョブの処理を継続します。この結果、CPU使用率は大幅に減らすことができましたが、アプリケーションのデプロイ手段がやや複雑になるという犠牲を払う必要があります。The Artisan queue:work command now supports a --daemon option to start a worker in "daemon mode", meaning the worker will continue to process jobs without ever re-booting the framework. This results in a significant reduction in CPU usage at the cost of a slightly more complex application deployment process.

デーモン・キュー・ワーカーに関する情報は、キューのドキュメントをご覧ください。More information about daemon queue workers can be found in the queue documentation[/docs/queues#daemon-queue-worker].

メールAPIドライバーMail API Drivers

Laravel4.2は、新しいMailgunとMandrill APIドライバーをメール機能に導入しました。多くのアプリケーションにとって、SMTPを使用する選択肢よりも、メールを送信する手段として、より早く、より信頼が置けるでしょう。新しいドライバーは、Guzzle 4 HTTPライブラリーを使用しています。Laravel 4.2 introduces new Mailgun and Mandrill API drivers for the Mail functions. For many applications, this provides a faster and more reliable method of sending e-mails than the SMTP options. The new drivers utilize the Guzzle 4 HTTP library.

ソフトデリート・トレイトSoft Deleting Traits

PHP5.4のトレイトを使用し、「ソフトデリート」の構造をより美しくし、「グローバルスコープ」を導入しました。この新しい構造により、グローバルトレイトに似た簡単な記述法ができ、フレームワーク内部の関心の分離をよりきれいに実現できます。A much cleaner architecture for "soft deletes" and other "global scopes" has been introduced via PHP 5.4 traits. This new architecture allows for the easier construction of similar global traits, and a cleaner separation of concerns within the framework itself.

新しいSoftDeletingTraitに関する詳細はEloquentのドキュメントをご覧ください。More information on the new SoftDeletingTrait may be found in the Eloquent documentation[/docs/eloquent#soft-deleting].

便利な認証とパスワードリマインダーのトレイトConvenient Auth & Remindable Traits

Laravel4.2は、認証とパスワードリマインダーのユーザーインターフェイスに必要なプロパティを含むシンプルなトレイトを使用するようになりました。これにより、初めから含まれているデフォルトのUserモデルファイルをより美しく提供できます。The default Laravel 4.2 installation now uses simple traits for including the needed properties for the authentication and password reminder user interfaces. This provides a much cleaner default User model file out of the box.

シンプル・ペジネーション"Simple Paginate"

新しいsimplePaginateメソッドが、クエリーとEloquentビルダーに追加され、ペジネーションビューに、シンプルな「次」と「前」リンクを使用したい場合に、より効率的なクエリーが行えるようになりました。A new simplePaginate method was added to the query and Eloquent builder which allows for more efficient queries when using simple "Next" and "Previous" links in your pagination view.

マイグレーション時の確認Migration Confirmation

実働時には、破壊的なマイグレーション操作には、確認を尋ねるようになりました。コマンドをプロンプト無しで実行する場合は、--forceオプションを使用してください。In production, destructive migration operations will now ask for confirmation. Commands may be forced to run without any prompts using the --force command.

Laravel 4.1Laravel 4.1

完全な変更リストFull Change List

今回のリリースの完全な変更リストは、インストールした4.1でphp artisan changesコマンドを実行することで表示されます。もしくは、GitHub上の変更JSONファイルをご覧ください。The full change list for this release by running the php artisan changes command from a 4.1 installation, or by viewing the change file on Github[https://github.com/laravel/framework/blob/4.1/src/Illuminate/Foundation/changes.json]. These notes only cover the major enhancements and changes for the release.

新SSHコンポーネントNew SSH Component

全く新しいSSHコンポーネントがこのリリースで導入されました。これが提供する機能は、SSHを使い簡単にリモートサーバーでコマンドを実行することです。詳しくは、SSHコンポーネントのドキュメントをご覧ください。An entirely new SSH component has been introduced with this release. This feature allows you to easily SSH into remote servers and run commands. To learn more, consult the SSH component documentation[/docs/ssh].

新しいphp artisan tailコマンドは、この新SSHコンポーネントを活用しています。詳細は、tailコマンドドキュメントをご覧ください。The new php artisan tail command utilizes the new SSH component. For more information, consult the tail command documentation[http://laravel.com/docs/ssh#tailing-remote-logs].

TinkerとBorisBoris In Tinker

php artisan tinkerコマンドは、システムがサポートしている場合、Boris REPLを活用します。この機能を利用するには、readlinepcntl PHP拡張をインストールする必要があります。これらの拡張が用意出来な場合は、4.0以上のシェルが利用できます。The php artisan tinker command now utilizes the Boris REPL[https://github.com/d11wtq/boris] if your system supports it. The readline and pcntl PHP extensions must be installed to use this feature. If you do not have these extensions, the shell from 4.0 will be used.

Eloquentの向上Eloquent Improvements

新しいhasManyThroughリレーションがEloquentに追加されました。どのように使用するかは、Eloquentドキュメントをご覧ください。A new hasManyThrough relationship has been added to Eloquent. To learn how to use it, consult the Eloquent documentation[/docs/eloquent#has-many-through].

また、新しいwhereHasメソッドがリレーションの条件に基づいてモデルを取得するために導入されました。A new whereHas method has also been introduced to allow retrieving models based on relationship constraints[/docs/eloquent#querying-relations].

データベースRead/Write接続Database Read / Write Connections

クエリービルダーとEloquent使用時に、データベース層でRead/Write接続により接続を自動的に分けられるようになりました。詳細はドキュメントをご覧ください。Automatic handling of separate read / write connections is now available throughout the database layer, including the query builder and Eloquent. For more information, consult the documentation[/docs/database#read-write-connections].

クエリーの優先度Queue Priority

queue:listenコマンドに、カンマ区切りでリストを指定することによる、キュー処理のプライオリティーがサポートされました。Queue priorities are now supported by passing a comma-delimited list to the queue:listen command.

失敗したキュージョブの処理Failed Queue Job Handling

queue:listenへ新しい--triesスイッチをつけることで、失敗したジョブを自動的に処理する機能が追加されました。失敗したジョブに関するより詳しい説明は、キューのドキュメントをご覧ください。The queue facilities now include automatic handling of failed jobs when using the new --tries switch on queue:listen. More information on handling failed jobs can be found in the queue documentation[/docs/queues#failed-jobs].

キャッシュタグCache Tags

キャッシュの"section"は"tags"に置き換わりました。キャッシュのタグにより、複数のタグをキャッシュアイテムにつけることができます。そして、タグを指定することで、一度に全部のアイテムを消去できます。キャッシュタグの使い方の情報は、キャッシュのドキュメントに記載されています。Cache "sections" have been superseded by "tags". Cache tags allow you to assign multiple "tags" to a cache item, and flush all items assigned to a single tag. More information on using cache tags may be found in the cache documentation[/docs/cache#cache-tags].

柔軟になったパスワードリマインダーFlexible Password Reminders

パスワードのバリデーション、セッションにフラッシュアイテムとして保存するメッセージの使用など、パスワードリマインダー(リセット)は、開発者が柔軟に使用できるように変更されました。修正パスワードリマインダーエンジンの詳細は、ドキュメントをご覧ください。The password reminder engine has been changed to provide greater developer flexibility when validating passwords, flashing status messages to the session, etc. For more information on using the enhanced password reminder engine, consult the documentation[/docs/security#password-reminders-and-reset].

ルーティングエンジンの向上Improved Routing Engine

Laravel 4.1ではルーティング層が完全に書き換えられています。APIに変更はありませんが、ルートの登録は、4.0と比べ完全に100%早くなっています。エンジン全体はとてもシンプルになり、ルートの解釈時のSymfony Routingへの依存が小さくなりました。Laravel 4.1 features a totally re-written routing layer. The API is the same; however, registering routes is a full 100% faster compared to 4.0. The entire engine has been greatly simplified, and the dependency on Symfony Routing has been minimized to the compiling of route expressions.

セッションエンジンの向上Improved Session Engine

このリリースでは、新しいセッションエンジンも導入しました。ルーティングでの向上と同様に、新しいセッション層はより小さく、早くなりました。Symfonyの(そのためにPHPのも)セッション処理機能を使用しなくなり、よりシンプルでメンテナンスしやすいカスタム処理を使用しています。With this release, we're also introducing an entirely new session engine. Similar to the routing improvements, the new session layer is leaner and faster. We are no longer using Symfony's (and therefore PHP's) session handling facilities, and are using a custom solution that is simpler and easier to maintain.

Doctrine DBALDoctrine DBAL

もしrenameColumn機能をマイグレーションで使用している場合、composer.jsonファイルにdoctrine/dbalパッケージを追加する必要があります。このパッケージはデフォルトではLaravelに含まれなくなりました。If you are using the renameColumn function in your migrations, you will need to add the doctrine/dbal dependency to your composer.json file. This package is no longer included in Laravel by default.

章選択

設定

明暗テーマ
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!…]形式の挿入削除行の表示形式です。

Pagination和文
ペジネーション
ペギネーション
ページネーション
ページ付け
Scaffold和文
スカフォールド
スキャフォールド
型枠生成
本文フォント

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

コードフォント

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

保存内容リセット

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

ヘッダー項目移動

キーボード操作