Y-KANOH
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    https://rakus.connpass.com/event/285602/ # PHPer's NEWS ::: info **[【PHP8.3】str_padがRFCで賛成多数で可決](https://php-rfc-watch.beberlei.de/rfc/mb_str_pad)** https://wiki.php.net/rfc/mb_str_pad ::: ::: info **[PHPカンファレンス福岡2023](https://phpcon.fukuoka.jp/2023/)** ::: ::: info **[PHPカンファレンス北海道2024 開催決定](https://twitter.com/yamato_sorariku/status/1670035943523516418)** ::: ::: info **[How to use GitHub Copilot: Prompts, tips, and use cases](https://github.blog/2023-06-20-how-to-write-better-prompts-for-github-copilot/)** ::: ::: info **[Build Your Own Service Container in PHP - Minimal Container](https://dev.to/jackmarchant/exploring-async-php-5b68)** exec() も立派な方法。 個人的にはキューとワーカーの構成が好きだなと感じました。 ::: ::: info **[CakePHP 5.0.0-RC1 released](https://github.com/cakephp/cakephp/releases/tag/5.0.0-RC1)** ::: ::: info **[#[Override] in PHP 8.3](https://stitcher.io/blog/override-in-php-83)** 言語使用に静的解析できるものを追加するのはいかがなものか、といった派閥も一定数あるようだったが、 RFC の投票フェーズでは賛成多数。 皆さんはどう思いますか? ::: ::: info **[みんなが幸せになれるPullRequestの作り方を考えてみた](https://qiita.com/marumaru0113/items/c53db580b812f8f6d4da)** ::: ::: info **[PhpStorm 2023.2 EAP #2](https://blog.jetbrains.com/phpstorm/2023/06/phpstorm-2023-2-eap-2/)** GitLabを使っている弊社としては地味に嬉しいかも ::: ::: info **[PhpStorm 2023.2 EAP #3](https://blog.jetbrains.com/phpstorm/2023/06/phpstorm-2023-2-eap-3/)** PHPStanでもつい最近サポートされた機能に早くも対応していて、スピード感に驚きました 参考:https://github.com/phpstan/phpstan/releases/tag/1.10.12 ::: ::: info **[AI Features in PhpStorm: PhpStorm 2023.2 EAP 5](https://blog.jetbrains.com/phpstorm/2023/06/ai-features-in-phpstorm-phpstorm-2023-2-eap-5/)** PhpStorm 2023.2 の EAP 5 告知。 AIアシスタントが付くらしい。。。 ::: # 特集:Symfonyを語り合う ## Symfonyとは? Symfonyとは https://symfony.com/at-a-glance#a-philosophy > ユーザーが自分のニーズに合わせて開発したアプリケーションよりも役立つものはあるでしょうか? これは Symfony の誕生の物語です。Symfony は、独自の Web 開発者である SensioLabs の Web デザイナーの想像力から生まれました。 Symfony は、オープンソース ライセンスに基づいて誰でも利用できるようになりました。 これは他の開発者にとっても有益であり、独自のモジュールを追加して改善することもできます。 これらすべては、アプリケーションのベスト プラクティス、標準化、相互運用性の環境で行われました。 Java の Spring Framework や Ruby の Ruby on Rails の影響を受けていることにより、「バンドル」という概念が用意されている。 Symfonyは、最初スポンサーである Sensio Labs の名前から “Sensio Framework” と呼ばれていた。クラス名には接頭辞として"sf"が付けられていた。OSSにするにあたって、“sf” がそのまま使える “Symfony” になった。(そのため"Sym**ph**ony"ではないので注意。) - コミュニティとサポート - [日本Symfonyユーザー会](https://symfony-japan.github.io/) - [symfony コミュニティ](https://symfony.com/legacy/doc/more-with-symfony/1_4/ja/15-working-with-the-symfony-community) 主な特徴 - モダンなアーキテクチャと設計原則 (MVC, モジュール性など) - 拡張性とカスタマイズ性 - コマンドラインツールの強力なサポート - ドキュメンテーションと学習リソースの充実 * [公式ドキュメント](https://symfony.com/doc/current/index.html) ## [Symfony Official Book](https://symfony.com/book) 日本語にも翻訳されている入門用ドキュメント。 [日本語の翻訳者](https://speakerdeck.com/ippey/symfonygong-shi-false-ri-ben-yu-ru-men-shu-gadekitayotutehua?slide=14)は以下の通り 入門用とされているが、以下について記載されており非常に重厚。 * 環境構築 * Docker * Git * MVC * DB * メール * イベント * 非同期処理 * セキュリティ * スパム対策 * デプロイ * 管理画面 * 認証 * ワークフロー * キャッシュ * テスト * Webpack * cron * Notification * API * SPA * 国際化 ## 開発環境 PhpStormであればプラグインあり https://plugins.jetbrains.com/plugin/7219-symfony-support ## Symfonyの好きなところは? * Symfony を知ることで設計力が高まる * Symfonyが良くできているため、良いコードを見ることで良い設計のノウハウが身につく * Symfonyを勉強してプログラム力が上がった * DIコンテナ * コンポーネントが疎結合 * Symfony Polyfillは神 * Twigの書き方がほかの言語のよく似ていて扱いやすかった * View内にPHPのコードを書ける * Twig Extension * [ここ参照](https://tech.quartetcom.co.jp/2020/12/24/why-we-choose-symfony/) ## SymfonyとLaravelの違い * Twig と Blade * Eloquent と Doctrine * Symfony * 正しく作る * HTTPの形を正しく表そうとしている * 正しく書かないと書けない(縛りがある) * HTTP Kernel * Laravel * 早く作る * 自分たちの発想を大事にして楽に作る * 立ち上げまではすごく楽 * [Laravelっぽくなったコンポーネント筆頭:Clock](https://symfony.com/blog/new-in-symfony-6-3-clock-improvements) * Clock については[こちら参照](https://github.com/hidenorigoto/test-greeter) * Symfony と Symfony UX が非常に強力 * [stimulus symfony](https://symfony.com/bundles/StimulusBundle/current/index.html) * [Live Components](https://symfony.com/bundles/ux-live-component/current/index.html) * SPAを作るにはフロントの知識がいるが、管理画面を簡単に作りたい時などは便利 * `.env` がコミット対象 * これがないとこけてしまうため ## Googleトレンドでの比較 https://trends.google.co.jp/trends/explore?geo=JP&q=Symfony,Laravel,CakePHP&hl=ja * 日本では Laravel 1強 * 世界では Symfony が去年あたりから逆転して1位に ## どんな時に選ぶフレームワーク?? * 常に候補に入るフレームワーク * 大規模なアプリを開発する、という印象だが現代のSymfonyはそんなことはない * 必要なものだけを追加して小さく始められる * 4.0 から小さくなった * コマンドラインが使える人が多いときは採用できる * コマンドラインが使えないとマイグレーションなども使いづらい * Laravelのマイグレーションとは大きく異なる * [Qiitaの記事参照](https://qiita.com/77web@github/items/158540fd4c1e379d1e9d) ## 使う時の注意点などはある?? * バージョンアップを怠らない * はじめてつかうときはエンティティに何でもさせようとしてしまう * Symfony的にやりにくいことを無理にやろうとしない * 後から苦しくなる * **getConteiner で get メソッドでクラスを取得しないこと** * DIコンテナを取得しない * 食わず嫌いせず使ってみることをおススメします! * 思った以上に使いやすいですよ ------------------- ## コンポーネントについて ### Symfonyコンポーネントとは Symfonyの構成要素であり、再利用可能なコンポーネント。 Symfonyはコンポーネントベースで構築されており、それぞれのコンポーネントは独立して使用できる。 ■Symfonyコンポーネント公式 https://symfony.com/components * [HTTP Foundation Component](https://symfony.com/components/HttpFoundation): HTTPリクエストとレスポンスを扱うためのコンポーネント。 * [Routing Component](https://symfony.com/components/Routing): URLとコントローラのマッピングを管理するためのコンポーネント。 * [Form Component](https://symfony.com/components/Form): フォームの作成、バリデーション、データの処理を行うためのコンポーネント。 * [Validator Component](https://symfony.com/components/Validator): データのバリデーションを行うためのコンポーネントです。 * [Security Component](https://symfony.com/components/Security%20Bundle): 認証や認可、アクセス制御を担当するコンポーネントです。 * [Cache Component](https://symfony.com/components/Cache): キャッシュ機能を提供するコンポーネント。 * [Console Component](https://symfony.com/components/Console): コンソールコマンドを作成、実行するためのツールセットを提供するコンポーネント。 ### Laravelで使用されているSymfonyコンポーネント SymfonyコンポーネントはLaravelでも使用されている。 https://symfony.com/projects/laravel * 認証、ルーティング、セッション、キャッシュなど多くの部分でSymfonyコンポーネントに依存している。 * LaravelがSymfonyに依存していることにより、SymfonyのリリースがLaravelのリリースに影響を及ぼすこともあった。 ### インストールと設定(久山) インストール方法は以下2種類 * Symfony CLI * Composer #### Symfony アプリケーションの作成 * Symfony CLI 経由でインストールする場合 ```bash= # Webアプリ作成に必要なコンポーネントが同梱されたアプリ作成手順 symfony new [任意のプロジェクト名] --version="6.3.*" --webapp # API作成手順 symfony new [任意のプロジェクト名] --version="6.3.*" ``` * composer 経由でアプリケーション作成する場合 ```bash= # Webアプリ作成手順 composer create-project symfony/skeleton:"6.3.*" [任意のプロジェクト名] cd [任意のプロジェクト名] composer require webapp # API作成手順 composer create-project symfony/skeleton:"6.3.*" [任意のプロジェクト名] ``` ### ルーティング #### routes.yaml に記載するパターン `routes.yaml` を以下の通り編集する ```yaml= app_lucky_number: path: /lucky/number controller: App\Controller\LuckyController::number ``` `/lucky/number` にアクセスすることで `LuckyController` の `number` メソッドにルーティングされる #### アノテーションまたはアトリビュートを利用するパターン(こっちが推奨) コントローラを以下の通り変更 ```php= <?php // src/Controller/LuckyController.php namespace App\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class LuckyController { #[Route('/lucky/number')] public function number(): Response { $number = random_int(0, 100); return new Response( '<html><body>Lucky number: '.$number.'</body></html>' ); } } ``` #### ルーティング設定の確認 ルーティングが正しく設定されているかを確認するための方法。 Symfony には `bin/console` というデバッガーが標準搭載されている。 以下のコマンドで正しく設定されているかどうかをチェックできる。 ```bash= php bin/console debug:router ``` ```bash= masaku@DESKTOP-IU10L8A:~/study/my_project_directory$ php bin/console debug:router -------------------------- -------- -------- ------ ----------------------------------- Name Method Scheme Host Path -------------------------- -------- -------- ------ ----------------------------------- _preview_error ANY ANY ANY /_error/{code}.{_format} _wdt ANY ANY ANY /_wdt/{token} _profiler_home ANY ANY ANY /_profiler/ _profiler_search ANY ANY ANY /_profiler/search _profiler_search_bar ANY ANY ANY /_profiler/search_bar _profiler_phpinfo ANY ANY ANY /_profiler/phpinfo _profiler_xdebug ANY ANY ANY /_profiler/xdebug _profiler_search_results ANY ANY ANY /_profiler/{token}/search/results _profiler_open_file ANY ANY ANY /_profiler/open _profiler ANY ANY ANY /_profiler/{token} _profiler_router ANY ANY ANY /_profiler/{token}/router _profiler_exception ANY ANY ANY /_profiler/{token}/exception _profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css app_lucky_number ANY ANY ANY /lucky/number -------------------------- -------- -------- ------ ----------------------------------- ``` ### セッション管理 フレームワーク上で利用する方法とスタンドアロンで利用する方法の二通りがある。 ### DBサポート #### 導入 Doctrine ```bash composer require symfony/orm-pack composer require --dev symfony/maker-bundle ``` .env 接続情報を記載 ``` DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name ``` #### エンティティクラスを作成する ``` php bin/console make:entity ``` #### 参考情報 [PHPのORM: DoctrineORMとEloquentの比較大全をひとりでやる Advent Calendar 2022](https://qiita.com/advent-calendar/2022/php-doctrine-orm-vs-eloquent) ### マイグレーション Doctrine Migrationsを使用。 ``` symfony console make:migration ``` マイグレーションを実行 ``` symfony console doctrine:migrations:migrate ``` レコード取得 ``` symfony console doctrine:query:sql 'SELECT * FROM vinyl_mix' ``` ### バリデーション #### 導入 ```bash composer require symfony/validator ``` config/validator/ ディレクトリ内の .yaml または .xml ファイルとして定義する * アノテーションがあれば .yaml または .xml ファイルは不要 * .yaml または .xml ファイルはサードパーティのシステムを利用する場合は必要 ##### 例)$nameプロパティが空の場合エラーとする ```php= Attributes // src/Entity/Author.php namespace App\Entity; // ... use Symfony\Component\Validator\Constraints as Assert; class Author { #[Assert\NotBlank] private $name; } ``` 用意するYAML ```yaml # config/validator/validation.yaml App\Entity\Author: properties: name: - NotBlank: ~ ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully