2

Okay, so apparently no one has had this problem since i can't find some one with the same issue as mine on the internet.

I have created a Laravel 5.3 project on my local machine and remote server and they work perfectly.

I created a repo in GitHub for the Laravel project and pushed the whole project to the repository. I cloned the repository to a different server and suddenly composer install and php artisan are breaking.

When i try to run php artisan it gives me this error: Could not open input file: artisan.

And when i try to run php composer.phar install or php composer.phar update it gives me this error:

Could not open input file: artisan
Script php artisan optimize handling the post-update-cmd event returned with error code 1

Any idea what's wrong? which files are required in the Laravel project to run artisan because i am pretty sure i included all the necessary ones. Thanks.

shay.k
  • 503
  • 1
  • 7
  • 15
  • 1
    try ssh into your server and do the artisan command – claudios Dec 20 '16 at 08:09
  • @claudios I am "sshing" to my server using ssh user@server.ip. is that what you mean? because it still doesn't work – shay.k Dec 20 '16 at 08:12
  • 1
    Could you post your error and all the steps that was done from your side? Couldn't say anything from the issue. You could also remove the vendor folder and reinstall using `composer update` or `composer install` on your remote server where it didn't worked. – PaladiN Dec 20 '16 at 08:14
  • @PaladiN steps: created new laravel 5.3 project -> checked that everything works fine -> uploaded project to github -> cloned the project in another server -> php artisan no longer works – shay.k Dec 20 '16 at 08:16
  • 1
    @shay.k could you give me the link to your github repo? I could inspect there if any. – PaladiN Dec 20 '16 at 08:18
  • 2
    Possible duplicate of [Could not open input file: artisan](http://stackoverflow.com/questions/26193314/could-not-open-input-file-artisan) – Ohgodwhy Dec 20 '16 at 08:25
  • 2
    One of those answers will address your question. – Ohgodwhy Dec 20 '16 at 08:25
  • 1
    Are you inside the Laravel installation folder? – GeoChatz Dec 20 '16 at 08:28
  • 1
    check if artisan file exists.. – kapilpatwa93 Dec 20 '16 at 09:38
  • @kapil.dev was on point on this. artisan file didn't exist. after adding it to git everything runs smoothly. i guess it was a stupid mistake but thanks to everyone any way! – shay.k Dec 20 '16 at 09:46
  • 1
    hahaha.. hope next time you come accross similar situation, you always troubleshoot from the basic rather than finding complex issue :P – kapilpatwa93 Dec 20 '16 at 10:01

4 Answers4

2

Try to remove the bootstrap/cache/config.php file. Then run again.

composer dumpautoload
composer update

This may work for you.

CrazyCrow
  • 4,125
  • 1
  • 28
  • 39
Henry Bui
  • 423
  • 3
  • 17
1

artisan file was not in git repository so i added than and it worked fine

shay.k
  • 503
  • 1
  • 7
  • 15
0

Laravel must have the artisan file in the root of the project. If it is not their, you will experience the error message which you have.

Laravel also requires a composer.json file to specify which dependencies must be installed.

Any missing files can always be found in the laravel repository on Github: https://github.com/laravel/laravel

Josh Bolton
  • 688
  • 6
  • 19
0

Sometimes if you don't have an artisan file in the root directory then create an artisan file inside of the project root folder and add this code snippet to work perfectly.

#!/usr/bin/env php
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/vendor/autoload.php';

$app = require_once __DIR__.'/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Artisan Application
|--------------------------------------------------------------------------
|
| When we run the console application, the current CLI command will be
| executed in this console and the response sent back to a terminal
| or another output device for the developers. Here goes nothing!
|
*/

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$status = $kernel->handle(
    $input = new Symfony\Component\Console\Input\ArgvInput,
    new Symfony\Component\Console\Output\ConsoleOutput
);

/*
|--------------------------------------------------------------------------
| Shutdown The Application
|--------------------------------------------------------------------------
|
| Once Artisan has finished running, we will fire off the shutdown events
| so that any final work may be done by the application before we shut
| down the process. This is the last thing to happen to the request.
|
*/

$kernel->terminate($input, $status);

exit($status);
NIKUNJ PATEL
  • 2,034
  • 1
  • 7
  • 22