質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

Q&A

解決済

1回答

572閲覧

Laravelで500エラーが表示されAPIの認証ができない

dauto

総合スコア38

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

0グッド

0クリップ

投稿2019/06/29 20:10

編集2019/06/29 21:10

開発環境

Laravel 5.8.26

困っている事

私は現在バックエンドにLaravelを使ってAPI認証を行おうとしています。しかし、POSTのリクエストをLaravelに送信すると500エラーが表示され、Logには下記のエラーが出力されていました。このエラーはどのように改善すればいいのでしょうか。

log

1local.ERROR: Class hash does not exist {"exception":"[object] (ReflectionException(code: -1): Class hash does not exist at /var/www/html/Laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php:790)

試した事

キャッシュをクリアして見ましたが、効果はありませんでした。

追記

エラーが出ているコードはこちらになります。

/var/www/html/Laravel/vendor/laravel/framework/src/Illuminate/Container/Container.php

php

1public function build($concrete) 2 { 3 // If the concrete type is actually a Closure, we will just execute it and 4 // hand back the results of the functions, which allows functions to be 5 // used as resolvers for more fine-tuned resolution of these objects. 6 if ($concrete instanceof Closure) { 7 return $concrete($this, $this->getLastParameterOverride()); 8 } 9 10 $reflector = new ReflectionClass($concrete); // ここがエラーが出ている790行目 11 12 // If the type is not instantiable, the developer is attempting to resolve 13 // an abstract type such as an Interface or Abstract Class and there is 14 // no binding registered for the abstractions so we need to bail out. 15 if (! $reflector->isInstantiable()) { 16 return $this->notInstantiable($concrete); 17 } 18 19 $this->buildStack[] = $concrete; 20 21 $constructor = $reflector->getConstructor(); 22 23 // If there are no constructors, that means there are no dependencies then 24 // we can just resolve the instances of the objects right away, without 25 // resolving any other types or dependencies out of these containers. 26 if (is_null($constructor)) { 27 array_pop($this->buildStack); 28 29 return new $concrete; 30 } 31 32 $dependencies = $constructor->getParameters(); 33 34 // Once we have all the constructor's parameters we can create each of the 35 // dependency instances and then use the reflection instances to make a 36 // new instance of this class, injecting the created dependencies in. 37 $instances = $this->resolveDependencies( 38 $dependencies 39 ); 40 41 array_pop($this->buildStack); 42 43 return $reflector->newInstanceArgs($instances); 44 }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

m.ts10806

2019/06/29 20:27

他者が再現確認できる最小限の構成で良いのでコードを提示してください。 現状だとエラーメッセージから調べた結果の記事を提示するくらいしかできませんし、既に質問者さんが調べた記事が回答に提示される可能性もあり、二度手間三度手間になりますので、そのあたり調べたことも追記願います
dauto

2019/06/29 21:11

申し訳ありません。先程エラーが発生している個所のコードを追記させて頂きました。
m.ts10806

2019/06/29 21:40

あいえ、フレームワークコアソースのコードではなく、ご自身が組まれたコードです。 APIとしてでしたら呼び出しているところもお願いします。
mikkame

2019/06/30 03:00

おそらくクラス名を文字列で渡すところを、インスタンスで渡してしまっている、みたいな感じでしょうね・・・
guest

回答1

0

自己解決

申しわけありません、認証の方式を変えたためこちらの質問は落とさせて頂きます。

投稿2019/06/30 13:42

dauto

総合スコア38

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問