{"id":23270433,"url":"https://github.com/umanari145/phptips","last_synced_at":"2026-01-31T13:39:36.949Z","repository":{"id":4804390,"uuid":"51076271","full_name":"umanari145/phptips","owner":"umanari145","description":"PHPに関わる小ネタ","archived":false,"fork":false,"pushed_at":"2024-08-24T01:18:11.000Z","size":19667,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T09:51:51.176Z","etag":null,"topics":["jwt","monolog","oauth","php","phpexcel","redis","sendgrid","trait"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/umanari145.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-04T13:03:29.000Z","updated_at":"2024-08-24T01:18:14.000Z","dependencies_parsed_at":"2023-07-05T19:32:23.685Z","dependency_job_id":"48188fbd-1c17-458d-a643-ea8334ce428b","html_url":"https://github.com/umanari145/phptips","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/umanari145/phptips","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanari145%2Fphptips","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanari145%2Fphptips/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanari145%2Fphptips/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanari145%2Fphptips/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umanari145","download_url":"https://codeload.github.com/umanari145/phptips/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umanari145%2Fphptips/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261200319,"owners_count":23123942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jwt","monolog","oauth","php","phpexcel","redis","sendgrid","trait"],"created_at":"2024-12-19T18:51:40.573Z","updated_at":"2026-01-31T13:39:36.921Z","avatar_url":"https://github.com/umanari145.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phptips\n\nPHP に関わる小ネタ\n\\*\\* laravel の dd を採用(\"larapack/dd\")\n\n- Anonymous\n\n  - call_user_func_array.php call_user_func_array を使ったリフレクション\n  - call_user_func.php call_user_func を使ったリフレクション\n  - clouser.php array_walk を使ったサンプル\n  - clouser2.php 無名関数、array_map、array_filter、array_column を使ったサンプル\n  - clouser3.php array_reduce を使ったサンプル\n\n- arrconvert\n\n  - make_hash.php プルダウン系のデータを配列の PHP コードにする\n  - hash_data.txt サンプルデータ\n\n- cached\n\n  - cached.php 静的キャッシュの使い方\n  - redis.php redis を使ったキャッシュ\n\n- CICD\n\n  - index.php エントリーポイントのファイル\n  - composer.json composer.json\n  - buildspec.yaml CICD 時の起動ただし、場所自体はルートディレクトリに\n\n- class\n\n  - SampleClass.php クラス変数とインスタンス変数の使い分け\n  - SampleClass2.php マジックメソッド\\_\\_call の使い方\n\n- closure\n\n  - array_convert.php clouser を使った array_map の自作\n\n- collection\n\n  - sample.php illuminate/collections をつかったサンプル\n\n- csv\n\n  - dummy.php CSV のインポート＆エクスポート\n  - load.csv CSV の読み込みとハッシュ化\n\n- date/date.php dateTime を使った日付の処理全般\n- date/Carbon.php Carbon を使った日付の処理/Immutable についても\n\n- di Di のサンプル\n\n  - type1\n    - Dog.php メソッドインジェクション、セッタインジェクション、コンストラクタインジェクション\n    - BuyFacade.php DI を使わないサンプル(内部でクラスの作成)\n    - BuyFacadeDI.php DI を使ったサンプル(create での結合をする)\n  - type2\n    - DogIncIF.php IF(interface)ありの Dog クラス\n    - CatIncIF.php IF(interface)ありの Cat クラス\n    - PetInterface DogIncIF と CatIncIF のインターフェイス\n    - Animal.php 注入される側(DI が使われてる側。ただし DI コンテナは使わない) 欠点としては具体的なクラスを記述する必要がある\n    - AnimalUseDIContair.php 注入される側(DI コンテナ:Pimple 使用 ) 利点としては IF 以下のクラスが見えなくても大丈夫(require_once は覗く)\n  - type3 DI コンテナをテスト用と本番用で手動で分ける(DI が一番効果を発揮する場面)\n    - SendMailIF.php sendmail 用のインターフェイス\n    - SendMail.php sendmail プログラム(クラスがここで入っていないので依存性がない)\n    - container.php DI コンテナ\n    - ProdSendMail.php 本番用の sendmail プログラム\n    - TestSendMail.php 開発用の sendmail プログラム\n\n- error エラーハンドリング\n\n  - errorCatch.php エラーハンドリングの具体例\n  - exception.php 例外キャッチに関して\n  - SentrySample.php エラーリポーティング(`https://sentry.io/settings/`で SENTRY_URL を取得)\n  - CustomException.php 独自の Exception\n  - MemberController.php Service の Exception のキャッチ\n  - MemberService.php 様々な例外のパターンを記述\n\n- encoding 文字コードがらみ\n\n  - mb_convert_encoding.php mb_convert_encoding の検出に関して\n  - cp932_text.txt cp932 で保存したファイル\n  - utf8_text.txt utf8 で保存したファイル\n\n- factory Factory パターンについてのサンプルコード\n\n  - 参考 https://liginc.co.jp/web/programming/php/149051\n  - AnimalController factory の呼び出し\n  - AnimalFactory 実際の具体生成箇所(正しく factory)\n  - Cat.php 具象クラス\n  - Dog.php 具象クラス\n  - Pet.php IF(Cat、Dog の上位)\n\n- filepointer ファイルポインタに関して\n\n  - file_pointer.php ファイルポインタの検出に関して\n  - sample_text.txt サンプルテキスト\n\n- import インポート系のスクリプト(CSV→DB など)に関して\n  - make_update_sql.php update 文作成\n    ```\n    ex.\n    php make_update_sql.php -i\"入力ファイル名\" -o\"出力ファイル名\" -k\"updateのkey\" -t\"テーブル名\"\n    ```\n  - make_insert_sql.php insert 文作成\n    ```\n    ex.\n    php make_insert_sql.php -i\"入力ファイル名\" -o\"出力ファイル名\" -t\"テーブル名\"\n    ```\n  - sample.csv サンプル CSV\n- invoke\n\n  - SampleClass.php invoke を内蔵したプログラム\n  - yobidashi.php 呼び出し側のプログラム\n\n- jwt JWT 認証のサンプル (uml/jwt.pu jwt のシーケンス図)\n\n  - login.php ログインの際に POST するプログラム\n\n    ```\n    curl -X POST http://localhost:8080/jwt/login.php \\\n    -H \"Content-Type: application/json\" \\\n    -d  '{\"username\": \"sampleUser\", \"password\": \"samplePass\"}'\n\n    #tokenの発行\n    {\"token\":\"xxxxxxxx\"}\n    ```\n\n  - data.php token を受け取り、実際にデータを返す部分\n\n    ```\n    curl -X GET http://localhost:8080/jwt/data.php \\\n    -H \"Content-Type: application/json\" \\\n    -H \"Authorization: Bearer XXXXX(token文字列)\"\n\n    # user情報が出力されていればOK\n    {\"username\":\"sampleUser\"}\n\n    #こけたら下記のように出力される\n     \"Signature verification failed\"\n    ```\n\n- logdir ログに関するテスト\n\n  - monolog.php モノログのサンプル 参考 https://gist.github.com/megatk/b7b7d9add34592d104a6 https://kzhishu.hatenablog.jp/entry/2015/10/04/200000\n  - Log.php monolog のラッパークラス\n  - logCallSample.php ログを呼び出すサンプル\n\n- last_static_binding 静的遅延束縛(self と static)による違いなど\n\n  - ParentClass.php 親クラス\n  - ChildClass.php 子クラス\n  - start.php 実際のクラスを呼び出す場所\n\n- mail メールのサンプル\n  - sampleSendMail.php(phptips_php7 コンテナの中に入って動かす)\n  - http://localhost:8025/ で GUI ツールにアクセス可能(実際にメールは送信されないでこのツールで仮想的に確認できる)\n  - mailhog.png は mailhog のスクショ\n- memory_management メモリ管理(メモリ節約のパターン)　参考 URL https://code-boxx.com/php-memory-management/\n  - unset_pattern.php unset のパターン\n- phpExcel PhpSpreadsheet を使ったサンプル\n\n  - PHPExcel PHP から Excel の読み書きを行うことができる\n\n- namespace namespace を使ったサンプル\n- oauth googleoauth を使った認証ロジック(uml/googleAuth.push 参照)\n\n  - cache テンプレートキャッシュディレクトリ\n  - template 　テンプレート(blade を単独で使用)\n    - login.blade.php ログインのテンプレート\n  - public\n    - login.js login 時の JS の実装\n  - index.php エントリーポイント(ログイン画面)\n  - config.json google アカウントなどの情報(clientID などの情報)\n  - config.json.sample テンプレート\n  - home.php ログイン後の画面\n  - loginCheck.php token の照合\n  - logOut.php ログアウト時の処理\n  - 参照リンク\n    - https://qiita.com/biy0ganba/items/6c3a886759254e0e942c フロント側の実装\n    - https://blog.4breaker.com/2020/06/03/post-1162/ フロント側の実装\n    - https://developers.google.com/my-business/content/implement-oauth?hl=ja google 公式\n    - https://console.developers.google.com/apis/credentials 認証情報の google 画面\n    - https://qiita.com/kmtym1998/items/768212fe92dbaa384c27 サーバーサイド側の実装\n    - https://code.tutsplus.com/tutorials/create-a-google-login-page-in-php--cms-33214 サーバサイド側の実装\n\n- pdflib pdf の活用\n\n  - pdfgenerateor.php fpdf を使ったサンプル\n  - pdfgenerateor2.php tcpdf を使ったサンプル\n\n- php\n\n  - tips PHP8 のネタ(名前付き引数、オブジェクトのプロモーション、null オペレーター)\n  - operator 演算子について(三項演算子、エルビス演算子、null 演算子) https://www.asobou.co.jp/blog/web/php-operator\n\n- redis redis のサンプル\n\n  - redisSample.php Redis のサンブル　 Redis コマンド自体は redis コンテナの中でみる\n  - http://localhost:8001/ で GUI ツールにアクセス可能\n  - redisinsigt.png は接続時の情報\n\n- reflection 動的クラスの作成\n\n  - Animal.php 親クラス\n  - Cat.php 子クラス 1\n  - Dog.php 子クラス 2\n  - ClassLoader.php autoload の作成\n  - reflection.php 実際の動的クラスの呼び出し\n\n- request\n\n  - curl.php curl コマンドでの POST\n  - file*get_contents*.php file_get_contents を使った POST\n  - #他に guzzle など HTTP クライアントを使った方がいいかも。。。\n\n- routing\n\n  - Controller 　コントーラー群\n  - Service 　サービス群\n  - Model 　モデル群\n  - .htaccess htaccess(主にファイルがなかった時に index を向かせる記述)\n  - index.php 実際のルーティングの記述\n\n- sendgrid\n\n  - sendgrid を使ったメールサンプル\n\n- scraping\n  - scraping paquettg/php-html-parser による PHP スクレイピング\n\n```\nhttp://localhost:8080/routing/sampleAction→Controller/TopControllerのsampleActionにアクセス\n参照リンク\nhttps://www.codit.work/notes/30lgs07yv3ycwjpz6p8y/\n```\n\n- trait trait の活用(外部実装)\n\n  - samplClass.php trait を受ける側の通常の野良クラス\n  - sampleProgram.php sampleClass を呼び出して実行するクラス\n  - sameplTrait.php Trait を実行するクラス\n\n- underbar\n\n  - scripts/summary.php underbar.php を使ったサンプル\n\n- util\n\n  - makeModel.php getter-setter を記載するプログラム\n\n- validation\n  - laravel の validation ライブラリ\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumanari145%2Fphptips","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumanari145%2Fphptips","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumanari145%2Fphptips/lists"}