<?php require __DIR__ . '/vendor/autoload.php';
Hello everyone,
I'm trying to run the Chat example but php is not able to resolve the needed libraries. I have installed composer and I have created the composer.json file. Composer then downloads the libraries and place them under the folder vendor. But when I run:
php chat-server.php
I get: PHP Fatal error: Interface 'Ratchet\MessageComponentInterface' not found in /home/luca/tmp/f3w/src/MyApp/chat.php on line 6
I think that there must be something wrong with my project structure, the folder/file structure is the following:
-src
--chat-server.php
--composer.json
--MyApp\chat.php
To run composer I use the following command: php /home/luca/bin/composer.phar install
What am I doing wrong?
Thanks in advance
{
"autoload": {
"psr-0": {
"MyApp": "src"
}
},
"require": {
"cboden/Ratchet": "0.2.*"
}
}This is how it looks my chat-server.php. I forgot to mention that I even had to add require_once otherwise it would not find my chat.php class
<?php
require_once("MyApp/chat.php");
use Ratchet\Server\IoServer;
use MyApp\Chat;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new Chat()
, 8080
);
$server->run();
I have changed chat.php to Chat.php, I have the same composer.json, and I have tried to re-run the composer but I still get the same error:
PHP Fatal error: Interface 'Ratchet\MessageComponentInterface' not found in /home/luca/tmp/f3w/src/MyApp/Chat.php on line 6
Thanks with this new structure it works.
However, I managed to test it only with telnet because with Javascript WebSocket it is not connecting. Is there a need of a special javascript library to connect?
You are right, I forgot about it. However there is still a problem, when I try to connect with the html/javascript page the chat-server.php die with:
PHP Fatal error: Call to undefined function Guzzle\Http\Curl\curl_version() in /home/luca/tmp/f3w/websocket/vendor/guzzle/http/Guzzle/Http/Curl/CurlVersion.php on line 47
Any idea?
I've the same directory structure that you write but I've this error :PHP Fatal error: Class 'MyApp\Chat' not found in /home/djnivek/projets/hpFam07/bin/chat-server.php on line 9
I had the same issue after following the install steps from http://socketo.me/docs/installand then changed composer.json as shown in http://socketo.me/docs/hello-worldi had to1. php /usr/local/bin/composer.phar install --devthis gave an error saying that composer.lock file had to be update2. php /usr/local/bin/composer.phar listto get help3. php /usr/local/bin/composer.phar update4. php /usr/local/bin/composer.phar validatethen it works.So its seems like composer.lock file was causing probs
I had the same issue after following the install steps from http://socketo.me/docs/installand then changed composer.json as shown in http://socketo.me/docs/hello-worldi had to1. php /usr/local/bin/composer.phar install --devthis gave an error saying that composer.lock file had to be update2. php /usr/local/bin/composer.phar listto get help3. php /usr/local/bin/composer.phar update4. php /usr/local/bin/composer.phar validatethen it works.So its seems like composer.lock file was causing probs
On Saturday, 11 May 2013 19:27:52 UTC+5:30, cboden wrote: