Install Laravel using Composer

十年热恋 提交于 2021-01-14 09:06:57

问题


I'm trying to install Laravel using Composer, but after running the following command

composer create-project laravel/laravel cmsLaravel 5.2

pointing to my c/xampp/htddocs directory, I get the error below:

C:\xampp\htdocs\laravelCMS\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\laravelCMS\bootstrap\autoload.php on line 17


回答1:


To install Laravel using composer, all you need to do is to run in your terminal is:

composer create-project --prefer-dist laravel/laravel blog

Where: blog is the name of the folder containing your new Laravel instance.

To install Laravel directly within your chosen directory (not in a folder within it as demonstrated above), simply run the same command but this time without a folder name as in:

composer create-project --prefer-dist laravel/laravel

Remember to run the command within your desired directory for the project; in your case, for C:\xampp\htdocs\, then, run either the first or second command as above base on your needs.

This assumes you already have Composer properly installed as recommended on their website.

Before you try addressing your failed to open stream: error, do avoid having folder names with space(s) as in your command above (obviously not the source of the error).

Make sure you have the correct Server Requirements for Laravel
the failed to open stream: error usually occur when the OpenSSL PHP Extension not enabled.

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

After enabling the required extension(s), do remember to restart your server, then run the following command:

composer update



回答2:


Follow the steps below;

  1. Download and install Composer.
  2. Go inside the folder C:\xampp\htdocs>(if you are using xampp) or C:\wamp\www>(if you are using wamp) and open cmd/PoweShell & run the following commands:

    • composer global require "laravel/installer"
    • composer create-project laravel/laravel (after running this command a folder having name Laravel will be created there)
    • Now go inside Laravel folder and run php artisan serve command.
  3. After executing the last cmd, it will show an URL: http://127.0.0.1:8000; access the URL in a browser, which should reflect the will see the default webpage of Laravel.




回答3:


You can just run

composer install

and it will process the required files to load the laravel in web browser

EDIT:

After seeing your comment, you should go to your laravel directory in your cmd.

cd C:\xampp\htdocs\laravelCMS

and run the command

composer install




回答4:


  1. Download and install composer
  2. Run composer global require "laravel/installer"
  3. Open terminal inside C:\xampp\htdocs and run laravel new my_folder_name



回答5:


Check your index.php and Change the path as per your project directory

Register The Auto Loader

require __DIR__.'/cmsLaravel /vendor/autoload.php'; 
$app =require_once __DIR__.'/cmsLaravel /bootstrap/app.php';



回答6:


Change your command to this:

composer create-project laravel/laravel cmsLaravel 5.2.*

This mean any sub version of laravel 5.2.




回答7:


composer create-project laravel/laravel 6.0

composer is a tool for dependency management in PHP

create-project is command to create a new laravel project

laravel/laravel is for the skeleton application you get when creating a new project. It provides a default structure that's recommended (you're not forced to use it). The repository contains default config files, controllers, routes, etc. As well as code responsible for bootstrapping the application.

Link Laravel/laravel

6.0 Version in laravel



来源:https://stackoverflow.com/questions/41975092/install-laravel-using-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!