Laravel 4 Artisan commands - php

I am having some trouble using Laravel 4's artisan. When running a basic
php artisan key:generate
I get this error:
[InvalidArgumentException] There are no commands defined in the "key" namespace
I've read in a few places and have updated composer with the command:
php composer.phar update
but this returns:
Nothing to install or update
and the problem still stands.
Any help will be very appreciated. Thanks.

Try to update composer itself first
php composer.phar self-update
then update you composer packages
php composer.phar update

Look for the file vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php - this is where the key:command is defined.
Then , look for vendor/laravel/framework/src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php - this is where the command is registered to be used with artisan.
Most likely something is messed up in your installation

Have you generated keys in Laravel 4 yet? The process is somewhat different from L3 in that you do not delete the 'Your key goes here!!!' text from this file.
app/config/app.php
You leave that text there and artisan writes over it.
You may already know this and be facing a different issue.

Related

How to Install Swagger to Laravel 8 API for documentation?

Installing Swagger for the First Time in laravel 8
composer require "darkaonline/l5-swagger"
composer require zircote/swagger-php
php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
Getting Error like:
I'm guessing the URL you're hitting might be incorrect. Change it to just docs/api-docs instead of docs/api-docs.json. In addition, if you haven't ran the generate command already, you would have to do so to make it work.
php artisan l5-swagger:generate

Laravel 5.5 - Issues creating new project

I'm trying to use Laravel 5.5. I updated my php 7.0 to php 7.1. Even, I update my laravel installer package. But, when I try to do:
laravel new myProject
I get this error:
You made a reference to a non-existent script #php -r
"file_exists('.env') || copy('.env.example', '.env');" You made a
reference to a non-existent script #php artisan key:generate
Illuminate\Foundation\ComposerScripts::postAutoloadDump You made a
reference to a non-existent script #php artisan package:discover
I am using laravel valet and if I go to the browser, when I try myProject.dev is not working. I see this error:
Whoops, looks like something went wrong.
I tried using:
php artisan key:generate
inside my project, but I got that:
[ErrorException]
file_get_contents(/Users/jorgeJimenez/Sites/laravel5-5/.env): failed
to ope n stream
: No such file or directory
I noticed, my laravel 5.4 projects are working. I copied a .env file and I put on my laravel 5.5 projects. After that, I run
php artisan key:generate
and the key was generated and my project in the browser works.
It's supposed, all that process is automatic, but I am not quite sure what is happening.
You can try update your composer:
composer self-update
I had the same problem. Then I found that there was no problem when i created the first project use laravel 5.5. so I clear composer's cache dir. It works well now.
This is because of your Laravel Installer or Composer version. I have faced the same problem and found following 2 different solutions:
Generally you can solve with by running composer global update command and then run composer update command from your project directory. This solution basically updates your installer and then your project.
If still, you have this issue, you need to run composer self-update command first and then run composer update command from your project directory. Here your composer will update and then your project.
Hope this answer will help you.

How to rollback last vendor publish in laravel

Hi have messed up my project by doing vendor publish here is the command last time i have executed (i'm using LARAVEL 5.4)
php artisan vendor:publish --tag=laravel-notifications
i want to rollback to previous state which was there before this command
what i was trying to do: i wanted to customize reset password email template
Problem: No longer i'm able to see my customized forgot password template and reset password template. but default template is appearing for both(forgot password and reset password).
Question : please help to get my previous state prior to running this command php artisan vendor:publish --tag=laravel-notifications
please help me thanks in advance!!!!
please help me thanks in advance!!!!
Got it working... The steps to remove a package from Laravel are:
Remove declaration from composer.json (in "require" section)
Remove Service Provider from "app/config/app.php" (reference in "providers" array)
Remove any Class Aliases from "app/config/app.php"
Remove any references to the package from your code.
Run "composer update vendor/package-name". This will remove the package folder from "vendor" folder and will rebuild composer autoloading map
it will remove the package folder from "Vendor" folder
I'm on a similar situation, but with Laravel 5.5
I think that the rollback in this situations does not exist.
When you execute this command:
php artisan vendor:publish --tag=laravel-notifications
a folder vendor/notifications is created under the views folder.
I have delete the notifications folder, and executed the command:
php artisan view:clear
and everything is working fine.
I know that this is an old question, but maybe someone find this useful
Try this: git clean -f -d
-d: for directory;
-f: for force;
This solved for me.

Fatal error: Class 'Illuminate\Foundation\Application' not found

I am getting following error when I open my site which is made using laravel 5
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
I have tried removing vendor folder and composer.lock file and running composer install it's not working I tried running PHP artisan optimize but it shows error
Fatal error: Class'Illuminate\Foundation\Application' not found
Is there any way to solve this problem?
Edited:
This problem aroused as soon as I used the php artisan make:model Page command which did create the model but then the above error gets displayed when I access the site
Also If use the Laravel's Local Development Server no such problem arises only if I use wamp server
In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.
I was able to use the --no-scripts flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.
composer update --no-scripts
Just in case I trip over this error in 2 weeks again...
My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.
Solution:
composer dump-autoload
composer install --no-scripts
make sure everything works now as expected (no errors!)
composer update
Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues
php artisan clear-compiled
composer dump-autoload
If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.
Easy as this, that worked for my project
Delete /vendor folder
and execute composer install
then run project php artisan serve
In my case composer was not installed in that directory. So I run
composer install
then error resolved.
or you can try
composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload
I just fixed this problem (Different Case with same error),
The answer above I tried may not work because My case were different but produced the same error.
I think my vendor libraries were jumbled,
I get this error by:
1. Pull from remote git, master branch is codeigniter then I do composer update on master branch, I wanted to work on laravel branch then I checkout and do composer update so I get the error,
Fatal error: Class 'Illuminate\Foundation\Application' not found in
C:\cms\bootstrap\app.php on line 14
Solution:
I delete the project on local and do a clone again, after that I checkout to my laravel file work's branch and do composer update then it is fixed.
I had accidentally commented out:
require __DIR__.'/../bootstrap/autoload.php';
in
/public/index.php
When pasting in some debugging statements.
For latest laravel version also check your version because I was also
facing this error but after update latest php version, I got rid from
this error.
run composer require laravel/framework after composer install then php artisan key:generate its work for me in kali linux
I can't imagine that anyone else reading this is a stupid as I was but just in case...
I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.
please test below solution:
first open command prompt cmd ==> window+r and go to the location where laravel installed.
try composer require laravel/laravel
i was having same problem with this error.
It turn out my Kenel.php is having a wrong syntax when i try to comply with wrong php8 syntax
The line should be
protected $commands = [
//
];
instead of
protected array $commands = [
//
];
#kalhan-toress 's comment is what ACTUALLY WORKED FOR ME
remove /bootstrap/start.php,composer.lock, and the vendor and run composer install
In my case, the error was caused on initial deployment because I didn't have a .env file in that directory (because those don't belong on Github where the files were transferred from).
check your .env file i think you miss something. Maybe like this
if yes then need to add manually and composer update or install composer

Unable to update Laravel 4 with Composer (Update: bug?)

Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.

Categories