How to install composer for portable - php

I have a repository with a bunch of code in it and a composer.json and a composer.lock.
When I want to run the website on a different server I have so clone the repo and then run composer install in the root of the repo.
However I want to be able to download the repo put it on a server and it should just work, without having to execute anything.
Even if I included the vendor folder in the repo and then try to put that on a webserver it gives me errors like "bla bla require() failed in some php file in vendor folder".
So what am I doing wrong?

A deployment of an application using Composer usually goes like this:
Checkout the appropriate version of the application from Git. You could also run git archive and pipe the result into tar to create a version that does not have the .git folder.
Run composer install
Transfer the created folder structure onto the target system.
All in all you'd probably only copy everything you already have on your development machine to the new system.
If that does not work, you have to be more specific with your error message.

Related

How to start using composer in your project after installation on Windows 10?

I downloaded the Composer-Setup.exe and run to install Composer using the installer within few mouse clicks.
Opened terminal by typing in cmd. At the command prompt typed in Composer and saw all the information related to Composer which means I've installed Composer successfully on my Windows 10 machine.
I'm using XAMPP for development. So, C:\xampp\htdocs\ is my document root directory.
I created a new directory titled composer_demo in document root. The path of which is C:\xampp\htdocs\composer_demo
Now, I want to use composer in this directory. How should I use it?
I went through the documentation but it's not saying anything clearly whether I've to create the composer.json file manually inside the directory composer_demo or what?
Do I need to write the dependency package manually into composer.json file manually or what like?
{
"require": {
"monolog/monolog": "1.0.*"
}
}
I'm clueless. Please someone give me step-by-step instructions to use the composer inside my newly created directory composer_demo.
Thanks.
It is just like you said, create a composer.json file on your composer_demo folder, be sure that it is not a text file with a hidden .txt ending. Open the shell inside the folder using shift + right click and selecting ‘Open Command window here’ and run
composer install
This command tells Composer to install your dependencies, not Composer itself. It will search for a composer.json file and download every dependency you listed there into a vendor folder. Composer will generate a composer.lock file with the versions it downloaded so you don't have problems once the third party libraries update.
run .exe file
give php path to C:\xampp\php
and
give istallation path to C:\xampp\htdocs\composer_demo.
Run shell or cmd
go to your directory. with typing cd C:\xampp\htdocs\composer_demo\
now type your keyword ex:- for install php-ffmpeg composer require php-ffmpeg/php-ffmpeg

File ./vendor/autoload.php missing or not readable in phpmyadmin

This question is different from: https://stackoverflow.com/questions/36150377/missing-vendor-autoload-php
I want to contribute to phpmyadmin. I cloned the github repo in my machine using Github Desktop software. I copied the downloaded files in xampp so that I can run phpmyadmin. But when I launch the phpmyadmin page, this error occurs:
File ./vendor/autoload.php missing or not readable.
Most likely you did not run Composer to install library files.
Where can I get that file? I saw something that uses composer create-project command but I don't get that where should I type that command?
I also downloaded phpmyadmin from their website and copy pasted in xampp directory and it worked well. It didn't give any such error.
What should I do?
This changed as of v4.7.0
https://www.phpmyadmin.net/files/4.7.0/
Starting with this version, phpMyAdmin uses Composer to manage PHP library dependencies while under development.
Users downloading the official source distribution will not notice a difference, however users of the git repository
should refer to https://docs.phpmyadmin.net/en/latest/setup.html#installing-from-git for details.
Here's the change PR for those interested: github.com/phpmyadmin/phpmyadmin/pull/11976
When you download or clone phpMyadmin it's missing the vendor folder, which is installed by Composer.
Open the phpMyadmin folder and run the composer install command. This will download and install third party dependencies and generate the vendor/autoload.php file.

cs-cart add on giving error cscart-sdk is not recognized

I have developed a cs cart add on, But when I make a zip of it and try to upload it from gui it gives wrong structure data
so after little research I got that, I have to follow some steps of given in following url.
https://github.com/cscart/sdk
But after successful installation of composer, When I run the command
cscart-sdk command:name
It gives me error
cscart-sdk is not recognized as an internal or external command
I am very new to cscart add-on development
There seems to be something wrong with your composer install, please follow this tutorial (this is where cscart also relates to)
Installation - Linux / Unix / OSX#
Downloading the Composer Executable#
Composer offers a convenient installer that you can execute directly from the commandline. Feel free to download this file or review it on GitHub if you wish to know more about the inner workings of the installer. The source is plain PHP.
There are in short, two ways to install Composer. Locally as part of your project, or globally as a system wide executable.
Locally#
Installing Composer locally is a matter of just running the installer in your project directory. See the Download page for instructions.
The installer will just check a few PHP settings and then download composer.phar to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
Now just run php composer.phar in order to run Composer.
You can install Composer to a specific directory by using the --install-dir option and additionally (re)name it as well using the --filename option. When running the installer when following the Download page instructions add the following parameters:
php composer-setup.php --install-dir=bin --filename=composer
Now just run php bin/composer in order to run Composer.
Globally#
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH, you can access it globally. On unixy systems you can even make it executable and invoke it without directly using the php interpreter.
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
mv composer.phar /usr/local/bin/composer
Note: If the above fails due to permissions, you may need to run it again with sudo.
Note: On some versions of OSX the /usr directory does not exist by default. If you receive the error "/usr/local/bin/composer: No such file or directory" then you must create the directory manually before proceeding: mkdir -p /usr/local/bin.
Note: For information on changing your PATH, please read the Wikipedia article and/or use Google.
Now just run composer in order to run Composer instead of php composer.phar.

Trying to open a PHP application locally

I'm trying to open a CakePHP application locally that had a composer.phar file but did not have composer.json file.
I created a default composer.json file, went into the app & console folders and tried to use bin/cake server to open the application but it shows bash: bin/cake: no such file or directory.
I am pretty sure there is one file that I need to open that will open the whole program, is there a certain file I should be looking for? Am I missing a step?
Without a composer.json file you cannot run composer.phar install to install all the dependencies.
So you have to proceed with a "try and fail" approach.
First of all, create the default composer.json file required to run a standard installation of CakePHP and install with composer.phar install.
Then check the App class and look for third party packages: add them to the composer.json file and update.
Then start using the application and read the exceptions: there you will find info about other required dependencies. Add them to the composer.json file and then update.
This may take some time to be done but in the end you will have again a working application.
Except if private packages are required: in this case you will have hard times.
Hope this can help you! In bocca al lupo!

How to get vendor folder in github project

Ive downloaded a helper library of an API written in PHP from GITHUB, but when I download the .zip file it doesnt contain vendor folder, but everywhere in the code it is seeking some files from vendor folder-which is error in running.
Can you help me how to get these? new to the system.
If you're working with PHP and you can't find a vendor/ directory that you expect to see, that PHP codebase probably uses Composer:
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
One surefire way to know that a project uses Composer (aside from reading its documentation) is to see if there are composer.json and composer.lock files (probably) in the root of the repository. These files define the project's dependencies.
To generate the vendor/ directory,
install Composer,
there are a few ways to do this, and it is OS-dependent, but something like curl -sS https://getcomposer.org/installer | php should work if you're on Linux or OSX,
open a terminal and cd into the project directory,
run composer install,
depending on how you installed Composer, you may have to run php composer.phar install instead,
wait for Composer to do its thing.
Composer will download your dependencies, putting the code into vendor/, and generate an autoloader class that hooks everything together. Depending on what the dependencies are it might also do other things, like linking all CLI binaries to vendor/bin/.

Categories