Ratchet 및 Laravel을 사용하여 websocket 응용 프로그램을 만들고 내 websocket 클래스 내에서 Eloquent 쿼리를 사용해야하지만 다른 네임 스페이스를 사용할 때 웅변을 사용할 수 없습니다. websocket 클래스. 여기 생성 된 클래스/다른 네임 스페이스에서 웅변을 사용하여 laravel에
클래스의 시작에 :use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class Socket extends Eloquent implements MessageComponentInterface, UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
이는 classmap와 composer.json입니다 :
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/libraries",
"vendor/cboden/ratchet/src" // added this
]
내가 원래 상태에서 composer.json을 변경했습니다 위와 같았습니다 :
...
"psr-0": { //removed this
"MyApp": "vendor/cboden/ratchet/src", //removed this
}
클래스 소켓은 app/libraries/Socket.php에 있습니다.
흠, 나는 내 마음에 오는 모든 것을 시험해 보았습니다. 누군가 내가 뭘 잘못하고 있는지 생각해 봤습니까?
가 발생 된 오류는 다음과 같습니다
use Socket;
및 소켓의이 행 15 : 나는 또한했습니다
class Chat extends Eloquent implements MessageComponentInterface, UserInterface, RemindableInterface {
PHP Warning: The use statement with non-compound name 'Socket' has no effect in /home/michael/PhpstormProjects/preisopt/app/libraries/Socket-Server.php on line 5
PHP Fatal error: Class 'Eloquent' not found in /home/michael/PhpstormProjects/preisopt/app/libraries/Socket.php on line 15
이 소켓 - 서버의 라인 5 같은 라인을 작성하려고 시도
class Chat extends \Eloquent implements MessageComponentInterface, UserInterface, RemindableInterface {
이이 오류가 발생합니다 :
PHP Fatal error: Class 'User' not found in /home/michael/PhpstormProjects/preisopt/app/libraries/Socket.php on line 35
이 라인 35 :
$dbtoken = User::where('username', '=', $split[1])->get('sockettoken');
모든 클래스와 모델이 존재하고이 클래스에서 사용하지 않을 때 노력하고 있습니다. 내가 여기에 시간에 의해 잘못된 몇 가지 이상한 물건이 될 수있는 많은 것들을 시도했습니다
...
'\ Eloquent'가가는 길입니다. 사용자가 네임 스페이스 안에 있습니까? 그렇지 않으면'\ User' 만하십시오. – lukasgeiter
\ DB \ Eloquent를 Eloquent로 사용하십시오. – Anthony