How to Install Swagger to Laravel 8 API for documentation? - php

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

Related

Laravel 8 UI issue

I have installed Laravel 8 as a new project. When I run the project I get the "In order to use the Auth::routes() method, please install the laravel/ui package." But Laravel installation doc says that laravel ui is depreciated and that we should use Jetstream. So I installed Jetstream with the Livewire stack. Back to test the project and I get the same error msg.
I have run a composer dump-autoload.
What do I have to do to get a Laravel 8 project to run?
You will need to clear and recreate cache. Run the following php artisan commands:
php artisan cache:clear
php artisan config:cache
php artisan route:cache
I had this problem as well on many 'upgrades' from earlier versions of Laravel. I don't want to change the entire auth mechanism, as it works, so I will keep the code I have.
#Elisha Senoo's answer is correct, and solved it most of the time. However, if you find yourself unable to clear the cache (because it has the same error message on the artisan command), the solution is to manually clear the .php files within the bootstrap/cache folder and then php artisan config:cache.

Issues using php artisan on a laravel 5.7.* app

I've been trying to work on a laravel app but I can't even make it start.
I've run composer install, composer global update, composer udpate, composer self-update and several other commands,
I've deleted the vendor folder, the composer.lock file, re-ran composer install and things I've found online to no avail. This is the error I keep getting:
#php artisan package:discover
In Container.php line 779:
Class request does not exist
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
Not sure where to go next. Any ideas?
I would suggest you remove your composer itself and re-install the composer. the try install you laravel packages with it.
Try clearing application cache using this command: php artisan cache:clear
The cache:clear command can be used to clear the applications cache files.
Don't worry about your laravel
check composer correctly installed on your system
check composer have access for READ and WRITE in your system
after your sure about things
check your laravel install in your system for PHP you have and find specific you php version composer connected to it (Those who have multi PHP)
then have two option:
composer global require laravel/installer
then laravel new blog or
composer create-project --prefer-dist laravel/laravel blog
then go to folder cd /projectName
Use PHP's built-in development server: php artisan serve

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.

Auth resources are missing in laravel

I want to make use of auth system which comes with the laravel package but the problem is when I make new laravel package using composer i.e composer create-project laravel/laravel project name --prefer-dist
it do not install those auth resources which includes (i.e. auth folder inside resources > views) and also I can't find the Services Folder inside app directory.
All other things are working fine except this authentication system.
What can be the possible problems? Please give me solution
I am working with MAMP.
Taylor Otwell has made it opt-in for Laravel 5.1
You need to run following command after installation
php artisan scaffold:auth
UPDATE
I think this has been answered here
You could also run the command php artisan make:auth in the root directory of you laravel project. I had the same problem and it worked for me.
The command php artisan scaffold:auth didn't work for me i don't know why.
it issued the error:
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "auth" is not defined.
Did you mean this?
make:auth
in Laravel 5.2 you just have to run this command "php artisan make:auth" and the auth folder will be created
Since laravel 6.* version make:auth is no longer supported, use ui:auth instead.
For deploying ui pack run
composer require laravel/ui --dev
then update composer.json :
composer update -W
and do the:
php artisan ui:auth
You need execute
php artisan make:auth
now if your style css and js are missing
You need load file .css and .js
1) execute in your project
npm install
2) then execute
npm run dev => now in folder /public now exist folder js and css
3) reload page

Laravel 4 Artisan commands

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.

Categories