php composer can't accessed inside public_html folder - php

I installed composer inside my server. Here is what my files look like via ssh
When i type composer from here it is working, but when i navigate inside public_html folder and type composer it is responding as -bash: composer: command not found like this.
What should i do to make composer accessible from public_html folder too

You can use the absolute path. It looks like composer is your home directory, so this should work:
~/composer
Another solution is to add the directory to your PATH.
However, you not install software in your home directory.
Install composer at a better location,
recommended by your operating system.
Then, that directory is likely to be already on PATH,
so simply running composer will work everywhere.

Related

composer.phar is not using the current directory's composer.json file

I'm trying to update my dependencies and running php [source_to_project]\composer.phar update via Windows CMD, but the composer is reading the composer.json file from the php.exe folder. I don't have composer installed in my system, and I could only just run the composer.phar file. I checked also the location of my php.exe, and inside this directory, I can see the vendor/[package] that I'm trying to install from my project (which is from different directory, containing composer.phar)
Any idea why is this happening?
PS: I was able to install/update/require last week using the same process and now I cant.
What is your COMPOSER env variable?
Maybe you can try this:
https://getcomposer.org/doc/03-cli.md#environment-variables
By setting the COMPOSER env variable it is possible to set the filename of composer.json to something else.
For example:
COMPOSER=composer-other.json php composer.phar install
The generated lock file will use the same name: composer-other.lock in this example.
Looking for like, a bunch of examples online, I figured out that I need to run the composer.phar while I'm on my project directory (ex.: [PATH_TO_PROJECT_SOURCE] > [PATH_TO_PHP]php.exe composer.phar [COMPOSER_COMMAND]), the problem was, I am running the composer command inside my php directory (since I am accessing the php executable to run the phar file, which should not be).

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

How to install composer for portable

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.

laravel installation on shared hosting with composer

I'm trying to learn Laravel and follow the instructions in their tutorial to install the framework on my shared hosting. I've disabled the secure-http option in composer but it still won't download the framework.
Called:
composer global require "laravel/installer"
Response:
Changed current directory to /home/sledzko/.composer
Warning: Accessing packagist.org over http which is an insecure protocol.
[LogicException]
Composer repositories that have providers can not load the complete list of packages, use getProviderNames instead.
What can I do to download the framework using composer?
Most of the shared hosting is not supported terminal/command access, that why it is not possible to install Laravel using composer on shared hosting.
But there is a way to use Laravel in shared hosting, you can install/setup Laravel project on a local machine and after that upload project (all directory structure and files) on your shared hosting. Only need to adjust public directory and bootstrap path in the index.php file.
Upload all files is in public folder in your shared hosting www/public_html folder, and all other folder structure in the separate folder. After that go to your index.php file in www/public_html folder and update below two linew with your path laravel folder path.
require DIR.'/../bootstrap/autoload.php';
$app = require_once DIR.'/../bootstrap/app.php';
Install package locally using Composer. The package folder will be created in the vendor path.
Copy vendor/packagename folder and paste it into your host's vendor path.
Replace your host vendor/composer folder with your local vendor/composer folder.
Replace your host composer.json with your local composer.json
please try:
composer create-project laravel/laravel --prefer-dist YOUR_PROJECT_NAME
This will help you to download the stable version on your machine!
If you use SiteGround you will be a lucky man, just must request access do ssh (over cpanel), and then run your composer command on terminal.
SiteGround servers already have composer globally installed.
BUT... you you want to do it on hard way, access you shell on Siteground and run:
wget https://getcomposer.org/composer.phar -O ${HOME}/composer.phar
echo "alias composer=\"/usr/local/php72/bin/php-cli ${HOME}/composer.phar \"" >> ${HOME}/.bashrc
source ${HOME}/.bashrc
composer --version
Just pay attention on php72 version, it's uses PHP 7.2. If you want or need another one do a ls /usr/local/ to see all versions.

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