8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHP3.0でプラグイン読み込みの方法がわからなかった

8
Posted at

背景

ひよっこエンジニアの自分が、PHPのことを何も知らずにCakePHP3でwebアプリ開発を始めてしまい、思ってるよりドキュメントが少なくて苦しい…

ので、自分の学びをシェアします。

参考までに環境は以下。

  • Vagrant 1.7.2
  • CentOS 6.5
  • PHP 5.4.45
  • CakePHP 3.0 <- ここ大切

vendor配下のプラグイン使用

Composerを使ってプラグインを読み込む方法はどこにでも書いてあるのだが、それをController内で使用する方法が見つからない…。

プラグイン(公式ドキュメント)を見て試してみてもうまいこといかない。

が、この記事のおかげで打開できた…!

その方法が以下。

composer.json
autoload: {
    psr-4: {
        "App\\": "src",
        "Facebook\\": "vendor/facebook/php-sdk-v4"    // これを追記
    }
}
SomeController.php
use Facebook;

// ...


public function index() {
    $fb = new Facebook\Facebook(['app_id' => /* ... */]);
}

まだまだ勉強。

参考資料

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?