While using composer autoload function, I faced annoying case.
For example for following situation:
I have 10 modules installed so far, and in the specific PHP, I just
want to load only needed module with it's dependencies.
What can I do?
If I do
require "composer/vendor/autoload.php";
it will load all modules' name space, and I DO NOT WANT THAT!
So let me explain exact sample case.
I have a Facebook SDK v4.0, which I manually downloaded last time. And there is code snap in, let say, a.php which is using this, by following code:
require 'facebook_v4/autoload.php';
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
Now, I have downloaded Facebook SDK v5 just by composer, with running following command:
composer require facebook/graph-sdk
And because I need to use other modules downloaded via composer, I added following line at very fist line of the a.php file:
require "composer/vendor/autoload.php";
Now it turns out it totally uses Facebook SDK v5 instead of v4, that 's why I just want to know the way to load ONLY needed modules by composer.
Please help me to figure out this case.
Thank you.
Related
I'm using OroCommerce and want to add a new packge using composer require
Before install my wanted package, composer display message like this
Reading composer.json of {package_name} ({version})
Composer seems to read all version of all my installed package.
It take so many time to read all version (by example package oroinc/platform have 199 releases)
There is a way to prevent this behavior
I answer myself (in case someone as the same question)
It's no possible https://github.com/composer/composer/issues/5943
In drupal 8, I am encountering modules that require libraries to be installed by Composer. However, I was wondering if I could skip the composer part and just install the libraries by hand.
Would I ever be able to do this?
(I have never gotten Composer to work)
Just extract the library at /libraries.
For colorbox, you should have root/libraries/colorbox/jquery.colorbox-min.js
But this way you miss the main purpose of composer cause it won't be possible to update all the dependence automatically.
I'm a webdeveloper and I'm starting a huge project requested by a company.
I'm trying to figure out if is best to use a PHP framework or not, and in case, which one.
I know Codeigniter, but I wanted to look around to see what's the best framework at the moment. I found out Laravel is trending at the top so I wanted to try it out.
Being used to Codeigniter I usually download the zip file with all the phps inside and start working. I'm trying to do the same with Laravel but I saw you are to download and use composer to install it.
I'm not really used to the Terminal and I wanted to ask if that's the only way of installing it or if there is a downloadable version as in Codeigniter, CakePHP, etc...
You can always download the ZIPped code directly from project's GitHub site. You can find the base application here: https://github.com/laravel/laravel - you'll find a link at the bottom of the right column. This code is what composer downloads when you use that to setup the application.
If you want to use Laravel you will have to use Composer as this is what the application uses to manage its dependencies. It's not hard, as you'll only need to run a few commands.
You can learn more about how to install and use composer in the docs: https://getcomposer.org/download/
A couple of years of go i used to program using PHP, but without frameworks. With these recent developments I've decided to get in the to the game and try using one. I've decided to use yii 2.0 .
I've read some of the documentation and in my opinion there is some lack of information (at least for who is getting started), so i´m having some problems installing yii 2.0 on my computer using Xampp. The PHP version is 5.5.9.
From what i could understand i downloaded the yii 2.0 framework, extracted the content and copied to c:\xampp\htdocs\yii2
I've already installed the composer, so the the next thing to do i think would be, using the cmd, do these two lines of code:
composer global require "fxp/composer-asset-plugin:1.0.0"
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
The problem is when i do the last one it asks for username and password i think of GitHub. Can you tell me if I'm obligated to have an account on github to install yii 2.0 framework.
Is there a way to get around this?
Yii2 is integrated with composer asset plugin. It allows download Bower and NodeJs packages through Composer.
Github account is required to overcome API rate limit. Here is the explanation from the main contributor of this extension:
It's a rate limit of Github API. In anonymous access, Github at a
greatly reduced limit (60/hr it seems to me), and we must be logged
with a token for have a much higher limit.
See composer/composer#1569 and composer/composer#1877
The problem also exists using Nodejs and Bower.
You can find it in this issue, it's 9th from the top.
I think workaround with installing Bower and the same packages is not an option, because initially and with each framework update you must manually synchronize packages with their versions and override some configuration. Also some extensions require javascript plugins and using composer asset plugin too. So you have to do the same with each of them too. It simply not worth it. And having account on Github for web developer nowadays is kind of de facto standard.
Just create Github account if you are still don't have one and everything should be fine. Earlier updating process was pretty slow, now it's faster and I found this approach pretty interesting and flexible.
Following the install instructions for composer here:
https://github.com/guzzle/guzzle
Next, run the Composer command to install the latest stable version of Guzzle:
composer require guzzlehttp/guzzle
This is straight forward and works.
After installing, you need to require Composer's autoloader:
require 'vendor/autoload.php';
I'm not sure about where to require the autoloader. Can anyone point me in the right direction.
Guzzle appears to work without this step but I'm looking for some clarification if this is needed and if so where to add the require.
I'm using Laravel 4.2 btw.
Thanks in advance.
If you're using Laravel 4.2 you don't need to do anything.
Laravel 4.2 automatically includes composer autoloader for you so you don't have to. If you were writing stand alone scripts, or your own framework, you'd need to require the autoloader yourself.
(Also, if the autoloader wasn't required, you wouldn't be able to instantiate Guzzle classes with manually requiring or including the files)