• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to install Composer to use Ratchet ?

#1
Hi,

I would like to test and learn websocket.

I found a lot of information, but I cannot understand what I have to do to have enabled Composer (http://socketo.me/) ?

Is it enough to enable Composer in the CI config file ?

Nothing to install ?
Anything else to do to make it work ?

=> $config['composer_autoload'] = TRUE; // default FALSE

Is what written in CI documention enough ?
=> https://codeigniter.com/user_guide/gener...t=composer

According to this tutorial :
https://c-mh.fr/posts/websockets-en-php-...n-y-parait

I can read :
"Ensuite, il vous faut composer, le "package manager" de PHP. Si vous ne l'avez pas, commencez par suivre ces instructions. En quelques mots, considérez cet outil comme un bidule qui va vous télécharger plein de bouts de codes et librairies PHP, à la demande et créer un fichier "composer.json" ainsi qu'un dossier "vendor" dans votre projet. En vérité, l'outil possède une super documentation et ça vaut le coup de se pencher sur le sujet si vous ne l'avez pas encore fait."

Google translation :
"Then you have to compose, the "package manager" of PHP. If you do not have it, start by following these instructions. In a nutshell, consider this tool as a gadget that will download you lots of code snippets and PHP libraries, on demand and create a "composer.json" file and a "vendor" folder in your project. In truth, the tool has great documentation and it's worth looking into it if you have not done it yet."

So, if I understand well, it says that after installation, I will have a "composer.json" file.
I found one composer.json file at /var/www/myproject.loca/
(myproject.local is CI framework)

This file is containing :
Code:
{
"description": "The CodeIgniter framework",
"name": "codeigniter/framework",
"type": "project",
"homepage": "https://codeigniter.com",
"license": "MIT",
"support": {
"forum": "http://forum.codeigniter.com/",
"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
"slack": "https://codeigniterchat.slack.com",
"source": "https://github.com/bcit-ci/CodeIgniter"
},
"require": {
"php": ">=5.3.7"
},
"suggest": {
"paragonie/random_compat": "Provides better randomness in PHP 5.x"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*",
"phpunit/phpunit": "4.* || 5.*"
}
}

It does not really sounds like something about Composer ?
Or am I wrong ?

So, I guess, I need an other composer.json file ?
How to make it, and where to install it ?

I do not have to do this ?
4 PHP commands to install Composer => https://getcomposer.org/download/

If Composer is already given with CI, I do not have to run, at least, the two last commands ?
Code:
php composer-setup.php
php -r "unlink('composer-setup.php');"
To get a composer.json file and a vendor directory ?

This tutorial also says I will find a "vendor" directory in my project, but I did not find any "vendor" directory in "application" directory, and anywhere else.

Thank you for helping and guide me !
Nils
Reply

#2
I finaly tryed to execute
Code:
composer require cboden/ratchet
shown in the tutorial https://c-mh.fr/posts/websockets-en-php-...n-y-parait

This let me understand that I need to install Composer.
I did that with
Code:
apt install composer
(I am running Ubuntu).

After that step done,
Code:
composer require cboden/ratchet
, I am confused.

The tutorial says :
Quote:Si votre projet est vierge de tout contexte "Composer", l'outil va vous demander diverses informations pour créer votre fichier "composer.json". Si tel est le cas, exécutez ensuite la commande suivante :

Google translation :
Quote:If your project is blank of any "Composer" context, the tool will ask you for various information to create your "composer.json" file. If this is the case, then run the following command : composer install

I dot not know if my brand new CI is blank or not of any "Composer context", how can I check this ?

Do I have to run, or not
Code:
composer install
?

Note that, the command
Code:
composer require cboden/ratchet
did not ask me anything to create the composer.json file.

Thank you for helping,
Nils
Reply

#3
I guess I have to add to CI composer.json file, the code found in composer.json file made by the command "composer require cboden/ratchet" ?

And copy the "vendor" directory made by the command "composer require cboden/ratchet" to CI "application" directory ?

Right ?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.