Install Yii2 extension manually without using Composer
It's highly recommended to use composer instead.
But if you want to do it manually:
1) Download archive of needed version from Github.
2) Open composer.json
.
3) Find PSR-4 autoload section and remember it, in your case: kartik/select2
.
4) Extract files to corresponding folder in vendor
: vendor/kartik/select2
(not yiisoft
!).
5) Add to vendor/composer/autoload_psr4.php
:
'kartik\\select2\\' => array($vendorDir . '/kartik/select2'),
6) Add to vendor/yiisoft/extensions.php
:
'kartik/select2' => array (
'name' => 'kartik/select2',
'version' => '2',
'alias' => array (
'@kartik/select2' => $vendorDir . '/kartik/select2',
),
),
samdark, one of the core contributors has the article in russian about it on his official blog here. It's basically brief translated version.
As you can see it's quite a lot of work to do. Multiply it by number of extensions and it becomes pain.
Seriously, use composer
. If the hoster doesn't support it, find another one.
how to add extensions to vendor manually in yii2
I suppose you have have used composer to install Yii2;
Use composer to add the required package:
composer require raiym/instagram-php-scraper
See also :
https://github.com/postaddictme/instagram-php-scraper#installation
This way, the classes will be added to composer autoload functionality
How do I install Composer PHP packages without Composer?
The composer.json
file lists the dependencies. In your example:
"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "^6.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0"
},
You must then find the corresponding packages in the packagist site. Repeat the same process for each dependency: find additional dependencies in their corresponding composer.json
files and search again.
When you finally have a complete list of the required packages, you only need to install them all one by one. For the most part, it's just a matter of dropping the files somewhere in your project directory. But you must also ensure that PHP can find the needed classes. Since you aren't using Composer's auto-loader, you need to add them to your own custom autoloader. You can figure out the information from the respective composer.json
files, e.g.:
"autoload": {
"psr-4": { "Coinbase\\Wallet\\": "src/" }
},
If you don't use a class auto-loader you'll need to figure out the individual require_once
statements. You'll probably need a lot of trial and error because most library authors won't care documenting that.
Also, and just in case there's confusion about this:
- Composer has an official GUI installer for Windows and a copy and paste command-line installation procedure for all platforms.
- Composer can be run locally and its output just uploaded elsewhere. You don't need SSH in your shared hosting.
- The command needed to install a library can be copied and pasted from the package web site—even if the package maintainer didn't care to document it, packagist.org generates it by default.
Composer is not perfect and it doesn't suit all use cases but, when it comes to installing a library that relies on it, it's undoubtedly the best alternative and it's a fairly decent one.
I've checked other answers that came after mine. They mostly fall in two categories:
- Install a library and write a custom download script with it
- Use an online web based interface for Composer
Unless I'm missing something, none of them address the complaints expressed by the OP:
- Learning curve
- Use of third-party software
- Possibility to develop right on the server (using SSH, I presume)
- Potentially deep dependency tree
Composer is not working for installing yii2 extensions
Use the following command to remove the permission warning and to make sure your user has permissions on the global composer folder.
sudo chown -R kaushalendra:<YOUR_GROUP> /home/kaushalendra/.composer
Note: to lookup which group your user belongs to
groups kaushalendra
For me, it shows the following groups
omeraslam : omeraslam sudo www-data docker
after
:
all are the groups my user is assigned i can useomeraslam
as username andomeraslam
as group so for me the command will besudo chown -R omeraslam:omeraslam /home/kaushalendra/.composer
Then run the following command on terminal
sudo apt-get install php-curl
Then restart apache
sudo service apache2 restart
Related Topics
Place PHP Results Inside HTML Page
Jquery Tablesorter Index Column Insert
How to Insert Multiple Rows Using Prepared Statements
Php: How to Get a List of Classes That Implement Certain Interface
Stemming Algorithm That Produces Real Words
Send Email with a Template Using PHP
Learning Select from Where Prepared Statements
How to Upload an Image as Attachment with Slack API
Write Utf-8 Characters to File with Fputcsv in PHP
PHP Allocate Color Without Image Resource
Mssql Query Issue in PHP and Querying Text Data
Combine 2-3 Transparent Png Images on Top of Each Other with PHP