Php artisan could not open input file

Не удалось открыть входной файл: artisan

Я думаю, что php artisan должен вызываться из корневой папки сайта laravel. или же эта ошибка появится.

Вам нужно выполнить команду ремесленника на том же уровне, что и каталог ремесленника. Это поможет вам в вашем проекте Laravel

Sidenote: Изначально я думал, что когда вызывается php artisan . , это была какая-то опция для команды php . Оказывается, это относится к файлу с именем artisan который находится в корне вашего проекта laravel. На самом деле он должен называться artisan.php так как это настоящий php-скрипт, но расширение для краткости опущено.

18 ответов

Вам нужно сначала создать проект Laravel, и если у вас уже есть, вам нужно перейти в этот проект с помощью команды cd в терминале, например cd myproject ,

Теперь вы сможете запускать любые команды artisan, например, запуск php artisan отобразит список доступных команд.

Эта ошибка появляется, когда я пытаюсь создать новый проект laravel: cd xampp / htdocs, затем composer create-project laravel / laravel newLaravelProject Он начинает загружать все необходимые зависимости, и внезапно появляется эта ошибка.

Если вы переместили папку своего приложения с помощью .env, папки vendor, папки config . и т. Д. В другое место, вам, возможно, придется изменить корневой каталог на это место.

Читайте также:  Остановить выполнение файла python

Вы не можете использовать php artisan если вы не laravel папке проекта laravel .

Вот почему он говорит: ‘Could not open input file — artisan’ .

Если вы выполните проект /home/forge/laravel-project/

Вы можете правильно выполнить свой ремесленник следующим образом

Во-первых, убедитесь, что вы находитесь в папке проекта laravel, иначе терминал не сможет найти файл artisan в каталоге проекта, и любой последующий запрос, запущенный вами для запуска сервера, будет отклонен.

демонстрация

Допустим, наше имя проекта laravel называется blog и находится в C:\laravel Тогда у нас будет: C:\laravel\blog

Где открыть терминал

Перейдите в C:\laravel\blog и откройте командное окно (терминал). Введите код ниже:

Код терминала Laravel для запуска сервера

php artisan serve —host 127.0.0.1

Мне просто нужно было сделать исполняемый файл artisan .

. и он работает без префикса php.

У меня также была проблема, которую я только что установил, но забыл перейти в созданную папку проекта. Так что вам нужно перейти в папку вашего проекта.

а затем служить php ремесленника команды

Вы должны находиться в папке проекта Laravel

При создании нового проекта с laravel new project-name будет создана папка с именем вашего проекта в качестве имени. Вы должны попасть в эту папку перед использованием любой команды php artisan , например php artisan serve , потому что файл-ремесленник находится в этой папке

Если это ваша первая установка laravel, то создайте еще один каталог/папку внутри каталога laravel, а затем перейдите в эту пустую папку и создайте другой проект с помощью команды ниже:

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

Это создаст новый проект с именем «блог», затем вернитесь в родительский каталог laravel и теперь вы можете запустить эту команду:

Вы получите возврат, такой как:

laravel deployment server started: http://localhost:8000 

Изображение 3549

Смотрите прикрепленное изображение

Источник

Laravel could not open input file artisan – How we fix it

Usually, the error shows up when a user tries to open the Laravel project outside the project folder.

At Bobcares, customers often approach us to fix Laravel errors, as a part of our Server Management Services.

Today, let’s see how our Support Engineers fix this Laravel error.

Laravel application structure

Laravel is a PHP framework for web application development. A composer is a tool that integrates the dependencies and libraries.

It includes the dependencies in the composer.json file. This file is usually placed in the source folder.

Laravel has a command-line interface. This is known as Artisan. It has a set of commands to assist web application development. To start the Laravel service, we use the command,

But in some cases, this ends up in errors. Our customers often approach us to fix errors while accessing the artisan console. Today, let’s discuss one such error.

Laravel error could not open input file artisan

Could not open input file: artisan

This is a very common error message that a Laravel user gets.

Usually, users get this error while trying to access a project using the command, php artisan . In the command-line, the error appears as,

Conclusion

So far we saw the reasons for the Laravel error could not open input file artisan. Incorrect console location and improper permissions trigger the error. We also saw how our Support Engineers fix it.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

5 Comments

Actually for me I don’t have the Author folder in my controllers folder. So I decided to use the php artisan:auth to create that inside my folder and the command was showing me “can not open input file” Reply

Hello Kuol,
The Auth folder will be located at App\Http\Controllers\Auth. Looks like there is something wrong in the command that you used to create auth file. This depends on the Laravel version that you are using. If you need further assistance, we’ll be happy to talk to you on chat (click on the icon at right-bottom). Reply

Worked, Thanks.
Please mak esure everybody to get to the exact project directory where all the files exist and project created. Reply

Hi Fahad,
Thanks for the feedback.We are glad to know that our article helps you solves the issue ? Reply

Источник

Could not open input file: artisan

I think, php artisan is to be called from the root folder of laravel site. or else this error will popup.

You need to run your artisan command at the same level as your artisan directory. This will make sure you are in your Laravel project

Sidenote: Initially I thought that when php artisan . was called, it was some sort of option for the php command. Turns out it refers to a file named artisan which is in the root of your laravel project. It should really be called artisan.php since it is an actual php script but the extension is omitted for brevity purposes.

Just try and execute the command in directory where all laravel code resides. Happened with me too, I was trying to run the command in project’s root folder, but the code was in a sub directory

25 Answers 25

You need to first create Laravel project and if you already have one you need to go to this project dir using cd command in terminal for example cd myproject .

Now you will be able to run any artisan commands, for example running php artisan will display you list of available commands.

This error appears when I am attempting to create a new laravel project: cd xampp/htdocs then composer create-project laravel/laravel newLaravelProject It starts to download all the required dependencies, and suddenly this error appears.

If you have moved your app folder with .env, vendor folder, config folder. etc to some where else, you may have to change directory root to this location.

You cannot use php artisan if you are not inside a laravel project folder.

That is why it says ‘Could not open input file — artisan’ .

I tried to make a migration from the migration folders, I hasd this message, you’ve got to be at the root of your application (where composer.json resides) to make it work

If you project is at /home/forge/laravel-project/

You can properly execute your artisan like this

Most probably you are not in the right directory!

I just needed to make artisan executable.

. and it works without the php prefix then.

First, be sure to be in the laravel project folder or else the terminal won’t be able to locate the artisan file in the project directory and any subsequent request you pulled to start a server would be rejected.

Demo

Let’s say our laravel project name is blog and located in C:\laravel We then have: C:\laravel\blog

Where to open terminal

Navigate to the C:\laravel\blog directory and open the command window (terminal). Input the code below:

Laravel terminal code to start server

php artisan serve —host 127.0.0.1

Make Sure your current directory is your project-name

First create the project from the following link to create larave 7 project: Create Project

Now you need to enter your project folder using the following command:

Now try to run artisan command, such as, php artisan .

Or it may happen if you didn’t install compose. So if you didn’t install composer then run composer install and try again artisan command.

If it is your first install of laravel then create another directory/folder inside the laravel directory and then move to that empty folder and create another project using the command below:

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

This will create a new project named «blog», then go back to parent laravel directory and now you can run this command:

You will receive the return such as:

laravel deployment server started: http://localhost:8000 

I checked out an existing Laravel project, which did not have this script. Even a find / -name ‘artisan’ produced no results. The solution turned out to be simple, if a bit weird:

curl -L 'https://raw.githubusercontent.com/laravel/laravel/v4.2.11/artisan' > artisan 

You probably want to choose a tagged version that matches your installed version of Laravel.

If you’re running your Laravel project in Vagrant and have just SSH-ed into the virtual machine, don’t forget to cd /vagrant before you try running artisan commands!

After struggling with this issue, I found out that you need to find where artisan resides by running sudo find / -name artisan , and from there run the command php artisan .

This error happens because you didn’t install composer on your project.

run composer install command in your project path.

You need to first create Laravel project and if you already have one you need to go to this project dir using cd command in terminal for example cd myproject.

Example : C:\xampp new\htdocs\project laravel\LaravelProject>php artisan serve

Now you will be able to run any artisan commands, for example running php artisan will display you list of available commands.

enter image description here

Mainly this may happen because your Laravel project opens on the wrong path. Just open the folder again in your code editor. That’s what happened to me when I got the same error.

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

After installing composer, you need to create the project:

composer create-project laravel/laravel /path/to/tour/project 

You can see the documentation, for your php version the lastest Laravel you can install is 5.0.

Now days here is the lastest version and require > php7.0. Here is the documentation.

What did the trick for me was to do cd src from my project directoy, and then use the php artisan command, since my artisan file was in the src folder. Here is my project structure:

project |__ config |__ src |__ app |__ .. |__ artisan // hello there! |__ . |__ . 

if you re in say my-project/app/somefolder run in terminal cd .. two times to get in my-project/ folder

Another thing to note that if you have a symbolic link from a non public location which hosts your project code to say public_html — running php artisan in the symbolic link location (public_html) will result in this error. You seem to need to be in the actual project directory for php artisan to work.

For those people that are having the same error on cPanel terminal specifically.

Now you need to enter into your project root or public_html folder in the terminal using the following command:

cd public_html

Now you will be able to run any artisan commands.

php artisan config:clear

enter image description here

Based on my experience, you must check if the artisan file is in your project folder. I had the same error, and when I check the artisan, it was not present. You can easily copy any artisan file from any existing or already working project and paste it into your new project.

Or you may download it here: artisan file

None of the solution worked for me. You can use these commands for solving the issue:

Remove bootstrap/cache/config.php file then:

composer dumpautoload composer update 

Remove vendor folder then:

If still not solved, your last option maybe to create new Laravel project: With new folder:

composer create-project --force laravel/laravel my-joyful-project 
composer create-project --force laravel/laravel . 

It should solve the issue. If still no, make sure you do not have older laravel version. And lastly, make sure that it is Laravel project you are working on, not Silverstripe. They are both using composer and have similar configuration files. Easy to mess up or maybe not 🙂

Источник

Оцените статью