How to build composer from a source code? - php

I have cloned repository from GitHub. So I am wondering how to build my own composer instance from the source files?

It also took me a while to find it, but the installation from source instructions are listed here in the Composer repository.
Basically you can install Composer from source with Composer, e.g. composer install. Very meta! Then you can use the Composer you've installed from source with path-where-you-cloned-composer/bin/composer. See the full instructions copied below:
Run git clone https://github.com/composer/composer.git
Download the composer.phar executable
Run Composer to get the dependencies: cd composer && php ../composer.phar install
You can run the test suite by executing vendor/bin/phpunit when
inside the composer directory, and run Composer by executing the
bin/composer. To test your modified Composer code against another
project, run php /path/to/composer/bin/composer inside that
project's directory.
(If you already have Composer installed globally, you don't need to do step 2.)

Related

How to start cloned rep Yii2

How can i start project cloned from bitbucket, based on Yii2, on my localhost?
Composer is installed.
When i clone it, composer update give me nothing. composer create-project --prefer-dist yiisoft/yii2-app-basic inside this project dont work, with error "folder is not empty".
When i use this command composer create-project --prefer-dist yiisoft/yii2-app-basic without clone rep, its work good, and i cant clone in just created folder?
How i can run cloned yii2 project on my localhost? Help pls. Sorry for my grammar.
Error after composer update (install)
Repository content.
Pluggins in install-plugins.bat
`php composer.phar require --prefer-dist mihaildev/yii2-ckeditor "*"
php composer.phar require kartik-v/yii2-widget-select2 "#dev"
php composer.phar require kartik-v/yii2-widget-datetimepicker "*"
php composer.phar require --prefer-dist yiisoft/yii2-imagine
php composer.phar require zelenin/yii2-slug-behavior "~1.5.1"
php composer.phar require --prefer-dist moonlandsoft/yii2-phpexcel "*"
php composer.phar require guzzlehttp/guzzle
php composer.phar require electrolinux/phpquery
UPD: Screen repository
It seems like, for some reason, the publisher of the repository added the dependencies to an extra file instead of them being added to the composer.json the usual way.
You can deal with this a couple of ways, both should give you the same results.
Option 1:
Install the Yii2 app into a new folder:
composer create-project --prefer-dist yiisoft/yii2-app-basic
Clone the repository you want to use into another folder.
Drag&drop the contents of the cloned repository into the Yii2 folder, it will overwrite the Yii2 files, preserving the ones that don't change and adding the ones that don't exist.
Add the extra dependencies, either by running the install-plugins.bat script or by hand running them one by one in the console.
Your project should be runnable now.
Option 2:
Clone the repository you want.
Copy the Yii2 composer.json into the root folder of the repository.
Run composer install
Add the extra dependencies, either by running the install-plugins.bat script or by hand running them one by one in the console.
Either way should give you the same results, you will end up having a vendor folder in the root of your project with all the dependencies, specified by composer.json and composer.lock that you need to run the project.

composer itself is managed by composer?

Maybe just a stupid question.
After I download/clone composer source code from github.com, how can I run it or compile it into a phar file?
When running "php bin/composer -v", it shows such errors:
php bin/composer -v
You must set up the project dependencies using `composer install`
See https://getcomposer.org/download/ for instructions on installing Composer
Is it said that I must download another composer.phar file and run "php composer.phar install" first?
I think it is a recursive way, "composer" itself is managed by composer :(
At first: if someone wants just to use composer, they must not install it from GitHub, just follow the installation guide: https://getcomposer.org/download/
OK, back to the question.
"composer" itself is managed by composer
Yes, and why do you think it is bad?
See the official documentation for contributors. It encourages exactly that way:
Run git clone https://github.com/composer/composer.git
Download the composer.phar executable
Run Composer to get the dependencies: cd composer && php ../composer.phar install
Then you can actually use composer by launching bin/composer, or you can compile it into phar by bin/compile.
If you wonder how are composer binaries actually built, you can see it in their Travis config. They just grab previous composer release provided by Travis, and build new composer release with it.
Composer's job is to locate and install dependencies for a particular project. Everything it does could be done by hand, mostly simply by placing files in the right location, and referencing a series of autoloaders.
In order to build Composer from scratch, you need certain code that is outside of the main Composer repository, such as command-line and logging helpers. You could download all of these manually, but the natural way is to use an existing install of Composer to fetch them.
This is only necessary if you are working on Composer itself, because once you have a successful build, you can produce a PHAR file, which contains all the required code including those third-party dependencies. These are the files distributed as official releases, and are all most people need; the tool even has a self-update command which downloads a new PHAR file and overwrites the one you ran.
This kind of bootstrapping - using an existing build of a tool as part of its own build process - is actually quite common. There are some parts of PHP itself which are generated using a PHP script, and I believe the first feature-complete C++ compiler was written in C++.

ERROR: Your system is not ready to run Symfony projects

I've downloaded a Symfony application and then checked it using php -f ./app/check.php. However, I get:
[ERROR]
Your system is not ready to run Symfony projects
Fix the following mandatory requirements
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Vendor libraries must be installed
> Vendor libraries are missing. Install composer following
> instructions from http://getcomposer.org/. Then run "php
> composer.phar install" to install them.
However, there is no composer.phar file in this application. e.g.
php composer.phar install
Could not open input file: composer.phar
Note: I already have composer installed.
Any suggestions?
The answer is right there in the error message you received.
Install composer following instructions from http://getcomposer.org/
Instead of composer.phar run:
php composer install
I think that's what you need. If you install Composer, then you probably renamed it to composer, and that's the bin you run.

What files to put on Bitbucket so that my teams could use?

I have a setup a Laravel 5 project locally and want to put it on bitbucket account so that my remote team mates can install it. Locally from command line I ran following command:
composer create-project laravel/laravel myproject --prefer-dist
which did everything. Now it sounds stupid to put all. I already uploaded my composer.json file. What instructions should I send out to team so that they just clone directory and install it? Do I dump each thing and they just clone it? Will they have to run composer create-project command anyway?
Here, no need to run composer create-project, they just clone the project and run composer install to deploy the project in their local.
As composer install will install all of the framework's dependencies, don't upload vendor folder to source (Bitbucket).
You can send following instructions
Project requirments
List of tools and technologies to run the project
Ex: PHP and mysql version, Frameworks (js, css) used and tools required NodeJs, Gulp, Bower or any other
Installation process
create folder project_name and clone project into it
open composer.phar and run composer install
setting up environment to run project with required tools

fuelphp Composer is not installed. Please run "php composer.phar update" in the root to install Composer

I am trying to install fuelphp.
And getting the error as
Composer is not installed. Please run "php composer.phar update" in the root to install Composer
In my xampp/php directory I run a command
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
But once i run php composer.phar install composer could not find a composer.json in e:\xampp\php
How can i resolve and run fuelphp successfully can anyone help.
As of 1.7.1, we no longer supply the composer.phar file in the zip. It only has a limited shelf life (30 days before it starts complaining).
Instead we suggest you install composer yourself, either locally (specific for this fuelphp installation) or globally so you only have to install it once for all your projects.
Composer is a tool for dependency management in PHP, like npm for Node.js, bundler for ruby, and others.
It reads a file called composer.json with the dependent libraries your project needs and, finally, installs (downloads) them for you.
Fuelphp can be installed using composer, but there are several packages.
So, you need to create the composer.json with all needed fuelphp packages. Open notepad, save a file with the name composer.json (be sure to save it with ".json" extension) and put this content:
{
"require": {
"fuelphp/upload": "2.0.1",
"fuelphp/event": "0.2.1",
(...)
}
}
Note you need to insert at "(...)" the others fuelphp packages and the needed versions. You can check them all at https://packagist.org/ (type fuelphp at search). Packagist is the main Composer repository.
More information about Composer at this link.
Let me know if you need more information about it.
If you are running FuelPHP 1.7, the download comes with all Composer files you need. You need to run php composer.phar install in the root directory of FuelPHP (the same directory that contains the public folder and the fuel folder.
As long as you have v1.7 (I'm not sure if earlier versions contain the files), that directory will contain composer.json and composer.phar.
In folder fuelphp-1.7 (latest), there are two files: composer.phar and composer.json you need to cd into that folder and run:
php composer.phar install
If you don't have php in your path, you should do something like:
e:\xampp\bin\php\php5.4.16\php.exe composer.phar install
Use the full path to your php.exe. Remember your current working directory should be fuelphp folder where composer.phar and composer.json are.

Categories