How to start cloned rep Yii2 - php

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.

Related

How to build composer from a source code?

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.)

Laravel composer.json fully istallation

Is there any way to install laravel from only composer.json file by using
composer install
command. If i just copy composer.json from existing project it creates only vendor directory, but not app, database, etc.
I just want to load all laravel core files, project file structure and my custom package by using install command of composer.
Can someone help me with this?
You can install laravel with the command composer create-project --prefer-dist laravel/laravel <project_name> if you only want to use composer, this command is mandatory since it creates the directories you want.
See the documentation
I don't think you can.
Create a new laravel project or clone an old project from git. Then replace/update the composer.json, then run composer update, if its a new project or composer install, if you cloned a repo
I didn't find solution for this, maybe it's impossible.
So, i just create my package and manually copy my custom composer.json to project.

PHP, Composer, PHP dependency manager

I am starting a new PHP project, and I wanted to pull some php components such as "nesbot/carbon" using composer. But when I create a composer.json file and try to run composer install command, it downloads other files from my previous projects that I don's want.
Even when I try to run "composer install" with out having a composer.json file in an empty folder, it downloads some previous dependencies from caches. I didn't get that from where it's reading composer.json. Am stuck in the middle of project.
How can I create a fresh project with composer?
To create a fresh project with composer, run
$ composer init
in the root directory of that project.
For reference, see https://getcomposer.org/doc/03-cli.md#init.

Difference between require and install vs create-project in composer

I don't get how the create-project works in composer. Lets take Laravel as example.
I can install this PHP framework with the following command:
composer create-project laravel/laravel --prefer-dist
This command installs the framework for me leaving me with a few folder in the root of my dir:
app
bootstrap
public
vendor
Plus some files.
But when I simply use the following composer command:
composer require laravel/laravel --prefer-dist
composer install
Then this only installs the vendor folder. No other files and folders are downloaded by composer.
How come? What is so different? How does composer know what other files to get when I use the create-project laravel/laravel command and why do I only get the vendor folder when I do require laravel/laravel?
require will add a dependency to the composer.json file and load it into the vendor directory as you have correctly noticed.
create-project on the other hand will clone the dependency, i.e. use the dependency as a template for a new project. Take a look at the repository behind laravel/laravel: https://github.com/laravel/laravel

How to clone repository with Composer without --prefer-source? (using Symfony 2)

Scenario: I am working with Symfony 2.2. In my list of required packages is also one of my github repositories, let's call it "TestLib".
I know that I can define the github url as additional repository in Symfony's composer.json to download "TestLib" via Composer from Github.
Problem: I cannot commit to "TestLib" repository as there is no local .git directory in the "TestLib" directory. I guess composer is fetching a zip from Github and not cloning it.
So my question is: is there a way to specifiy in Symfony's composer.json that Composer should clone TestLib?
Question 2: Maybe my workflow is wrong - so if you also have this scenario - how do you handle this?
Adding #dev to the package version clones the repository too.
{
"require": {
'package': '*#dev'
}
}
Also is possible setup source as preference in the composer.json
{
"config": {
"preferred-install": "source"
}
}
What I typically do if I notice that a vendor has an issue is rm -rf vendor/foo/bar to remove it and then I run composer install --prefer-source to get it back as a git repo.
What I did was add my github repo to packagist.org then I did this:
composer require malhal/createdby dev-master --prefer-source
This appears to add the require line to composer.json and also get it as a git repo, unfortunately this only works once so if you wouldn't be able to reuse the composer.json for a new install and would need to delete the require line and then remember to do this same command again. This command also downloads the git repo you don't have to do another composer update.

Categories