Skip to content

About

sample code for several design patterns in PHP

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Repository files navigation

DesignPatternsPHP

日本語翻訳版

Build Status

Documentation Status

Donate

Read the Docs of DesignPatternsPHP or Download as PDF/Epub

こちらの資料では知られたデザインパターンといくつかのサンプルコードを、PHP ではどのように実装するのかを記載します。

This is a collection of known design patterns and some sample code how to implement them in PHP. Every pattern has a small list of examples (most of them from Zend Framework, Symfony2 or Doctrine2 as I'm most familiar with this software).

デザインパータンについては知っていても、アプリケーションの中でどのように適用すればいいのかがよくわかっていないという課題があるように感じます。

I think the problem with patterns is that often people do know them but don't know when to apply which.

導入編

Installation

サンプルコードで何が起きているかを確認するためには実際にテストコードを実行して確認すべきでしょう。 そのために、composerを使って依存関係をインストールしてください。

You should look at and run the tests to see what happens in the example. To do this, you should install dependencies with Composer first:

$ composer install

Composerのインストールの仕方や使い方についてより深く知りたい場合はココで確認してください。

Read more about how to install and use Composer on your local machine here.

テストコードではphpunitを実行します。

To run the tests use phpunit:

$ ./vendor/bin/phpunit

Docker を使う(オプション)

using Docker (optional)

必要に応じてDocker for Mac, Windows or Linuxを使用してドキュメントを作成して閲覧することができます。

You can optionally build and browse the documentation using Docker for Mac, Windows or Linux.

実行方法は以下です。

Just run:

$ docker-compose up

http://localhost:8080/README.htmlにアクセスすれば、生成されたドキュメントを読むことができます。

Go to http://localhost:8080/README.html to read the generated documentation.

docker-composeを使うためには以下のようにして依存関係をインストールするだけです。

To only install the dependencies, use docker-compose like this:

$ docker-compose run php php composer.phar install

パターン

Patterns

デザインパターンはだいたい3つのカテゴリで構成されています。 📓をクリックするとすべての例を WikiPedia で確認することができます。

The patterns can be structured in roughly three different categories. Please click on the 📓 for a full explanation of the pattern on Wikipedia.

作成系

構築系

行動系

もっと

コントリビュート

Contribute

もし、サンプルコードにバグが見つかったり、翻訳間違いを見つけた場合は、お気軽にフォークして、変更内容のプルリクエストを送ってください。 ただし、コードの一貫性を維持するために、PHP_CodeSniffer を利用して PSR2 standard を実行してください。 実行方法は以下の通りです。 ./vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor ..

If you encounter any bugs or missing translations, please feel free to fork and send a pull request with your changes. To establish a consistent code quality, please check your code using PHP_CodeSniffer against PSR2 standard using ./vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor ..

About

sample code for several design patterns in PHP

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages