Ratchet: Problem managing libraries with composer.json
Hello,
I started to learn and use Ratchet recently and I have some issue in managing some libraries with composer.json. So, i started a project and installed composer. The content looks like this:
{
"autoload":
{
"psr-0":
{
"MyApp": "src"
}
},
"require": {
"cboden/ratchet": "0.3.*",
"react/zmq": "0.2.*|0.3.*"
}
}
It seems that the ratchet libraries are well managed since i have no problem to include them in my php scripts (ex. use Ratchet\Server\IoServer, etc) but for the rest of the libraries i have a problem.
For the first case, when i try to include my application in a php script with: use MyApp\TheClassName
it throws an error: “Class ‘MyApp\PDG’ not found in /srv/www/htdocs/pdg_realtime/bin/PDG_server.php on line 13”
so i have to add:
require dirname(DIR) . ‘/src/MyApp/PDG.php’; on the top of the document in order to work properly.
As for the second case, I have installed ZeroMQ. I have put the zmq library in vendor/react folder, unpacked it and installed it from there. The folder name is zmq as it is initialized on the composer.json file. However when i try to include a library from zmq like:
use React\ZMQ\Context; (the pusher example on the Ratchet portal )
it gives:
PHP Fatal error: Class ‘React\ZMQ\Context’ not found in /srv/www/htdocs/pdg_realtime/bin/PDG_server.php on line 16
on the line 16 i have: “$context = new React\zmq\Context($loop);”
it seems that composer.jason library does not manage zmq libraries well.
Any suggestions about these issues?
P.S The second case is much more important to me at the moment.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 22 (8 by maintainers)
After you install the composer dependencies you need to include the composer autoloader, not your files directly: