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.
Related
Via Terminal I installed the Ramsey/Uuid plugin:
composer require ramsey/uuid
In my PagesRepository.php I am creating this function:
use Ramsey\Uuid\Uuid;
function generateUid()
{
$uuid = Uuid::uuid4();
$uuid = $uuid->getHex();
$uuid = substr($uuid,0,10);
return $uuid;
}
I am using the function in my PagesController.php
$unique_id = PagesRepository::generateUid();
$entity->setUnique_id($unique_id);
It is working very fine on my local machine, but then I push it via git to my server and there I get the error message:
Attempted to load class "Uuid" from namespace "Ramsey\Uuid". Did you
forget a "use" statement for
"Symfony\Component\Validator\Constraints\Uuid"?
I cannot install anything on the server because it is a shared host and the permission is denied so I copied the ramsey folder into my vendor folder on the server. But this was not solving the problem.
I do not understand, why this is asking for the Symfony validator, as it does not need it on the local machine.
Its because of composer auto generated files not linking your folder or class (ramsey) .
So, as i understand you can not run composer update or composer install on shared hosting, you should upload whole updated vendor folder to your server.
Then auto generated files like vendor\composer\autoload_psr4.php will be updated and have link to class like Ramsey\Uuid\Uuid.
Point is
PHP Namespace can not include class/file automatically. It loads classes with composer's auto generated linking files and __auload magic function.
If you are not running composer install in your server, you need to copy the whole vendor folder, at least, to wherever you are running the system.
The package you have installed might have installed other dependencies, for example, but you are not copying them when transferring only the files for that package. And at the very least you'll need the generated autoloader files.
Since you creating the installation on dev and transferring it to production, I would advise delete your local vendor folder and re-do the whole installation first:
composer install --prefer-dist --no-dev --no-scripts --no-progress --no-suggest --classmap-authoritative --no-interaction
And transfer that vendor folder to production. You should make sure that the installation process doesn't include any other step (enabling bundles, creating configuration files, etc), but I'm hoping you took care of that at some point.
After yo do that, you can reset the previous steps, and do a regular composer install for development.
I wish to start a new symfony project,I want to use composer for the added advantages, but am having using the installed composer in my new project folder. The composer already installed came with Acquia dev desktop. when I run 'php composer.phar' in my new project folder I get this error "Could not open input file: composer.phar"
Double check where your composer.phar file is located.
If it has been installed into your old project's folder, simply copy it to the new folder.
If it has been installed globally (i.e: it is not in your old project's folder), then make sure you are using the right command, you might need to simply do composer install instead of php composer.phar
I was working with a laravel project and, accidentally, removed vendor folder.
What should I do? Create a new project and copy it or download it anywhere else?
I had no additional composer dependencies installed.
Just run composer install after cding into the Laravel project's directory.
The Vendor folder is created by running composer install. It contains only the packages which you have asked composer to track in the composer.json file. If you have a composer.phar file in the root of your application run php composer.phar install.
https://getcomposer.org/doc/00-intro.md is probably your best source for additional information.
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.
I am new to Laravel, I have installed the Laravel on my localhost using
WAMP server but I am getting an error after all steps.
The errors are:
( ! ) Warning: require(C:\wamp\www\laravel/../bootstrap/autoload.php): failed to open stream: No such file or directory in C:\wamp\www\laravel\index.php on line 21
( ! ) Fatal error: require(): Failed opening required 'C:\wamp\www\laravel/../bootstrap/autoload.php' (include_path='.;C:\php\pear') in C:\wamp\www\laravel\index.php on line 21
I have used below link for Laravel installation
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
I have tried to debug the issue but haven't found success in the installation.
Please let me know what is missing in installation.
You need to install Composer, open up the command prompt and cd to your directory (or hold Shift while right-clicking on your directory and clicking Open command window here) and there run composer install.
You can simplify the Laravel installation with Composers create-project command.
composer create-project laravel/laravel path
Laravel dependencies are not installed yet. That is why it is giving you this error.
https://getcomposer.org/download/
Go to this link and download composer if you haven't already.
Move the composer file to /usr/bin and rename it to just composer.
Go into the root directory of your laravel application. And run:
composer update
This will install and update all required dependencies.
In case you are on windows, which is less likely, but if you are, just download and install composer via the installer and issue the same command in you project's root directory.
Composer is PHP's dependency manager.
In the root directory of your laravel installation you will find a composer.json file. It contains the list of all your project's dependencies. If you ever need to install a package in your project, it becomes very easy. You just have to edit the composer.json file and let it know which package you need. Issuing composer update will install new package listings and update all existing ones.
just to be clear I'm not big fan of wamp.
I've just took quick look at the
http://www.wikihow.com/Install-Laravel-Framework-in-Windows
and I suppose laravel framework is not going to work best with point 11 to 14 modifications.
Baseline for laravel to work is you need to http serve /public folder in a properly configured environment (after composer install and create-project as described earlier).
If you want to take full advantage of laravel you need to often cli `php or composer (at least)` efficiently.
While using laravel I suggest installing PHP and MYSQL yourself from scratch (it really takes few minutes) and using convenient IDE (like PHPSTORM for example).
Nowadays PHP has builtin http server, so you don't need any http server in your dev environment.
So in Windows:
Install PHP and enable required libraries in php.ini
Install and configure local mysql server (easiest way installing via MySQL installer)
Start development server by invoking php.exe -S localhost:80 -t "absolute-path-to-your-laravel-installation\public" like for example C:\htdocs\laravel\public via commandLine
Enter url in your favorite browser http://localhost
Hope that will help to get you started.