Laravel 5.1 remove controller - laravel

I have simple question on Laravel 5.1. I have created a controller using php artisan command:
php artisan make:controller PageSettings
However it was mistake, because I really wanted to create this controller in Admin folder like this:
php artisan make:controller Admin/PageSettings
Now I want to get rid of my old PageSettings controller. Is it ok just to delete my old PageSettings.php manualy? Or there is something more what needs to be done?

If you only created it and found that you did it wrong, you can manually remove the file and that's it. However when you already added routes to this controller in routes.php you should remove them from routes.php file or alter the file to reflect your new controller.

It is OK to manually delete controller. Just check routes.php if you have some route to that controller and delete it also.

I had an issue with just deleting the file. I tried running my PHPUnit test suite and got an error that looked like this:
Warning: include(): Failed opening '/user/home/me/some/file.php' for inclusion (include_path='.:') in /usr/home/me/some/vendor/composer/ClassLoader.php on line 444
I had to run composer update then composer dump-autoload. After that, everything worked just fine.

Yeah, you can delete manually without tension.
I will suggest you for avoiding more mistakes, you "phpStrom" software, from using this, if you delete manually any file from by click right of mouse->Refactor->safe delete then before deleting they will give all places which were using your file. by clicking "do refactor" you can delete it.

Related

after Update laravel 6.2 [App\Http\Controllers\Auth\ConfirmPasswordController] does not exist

I update laravel from v 6.0 to v6.2 and after the finish, I try php artisan route:list
This error
I had the same issue, i fixed it with the following solution:
Create a empty file named "ConfirmPasswordController.php" in the folder App/Http/Controllers/Auth
Go to https://github.com/laravel/laravel/tree/master/app/Http/Controllers/Auth en open the file named "ConfirmPasswordController.php"
Copy all the file contents to your newly created file and save it.
This should fix the error.
Edit
The problem is, were updating the composer dependencies, but not the core application. But de composer dependencies expect you to update the core. They refer to files on the core application that not exists (because the application is not up-to-date).
See: How to update Laravel Application (not the composer dependencies)
This has been fixed. Just update to Laravel 6.4
Step1. Create ConfirmPasswordController.php file in app/Http/Controllers/Auth/ path.
Step2. ConfirmPasswordController.php paste this content to ConfirmPasswordController.php file.
From v6.0.0 to v6.2.0 the following addition and modifications were made.
Added app/Http/Controllers/Auth/ConfirmPasswordController.php
Modified app/Http/Controllers/Auth/ForgotPasswordController.php
Modified app/Http/Controllers/Auth/ResetPasswordController.php
Modified app/Http/Kernel.php
Modified config/auth.php
Modified resources/lang/en/validation.php
You can see the diff of v6.0.0 to v6.2.0 here.
Create ConfirmPasswordController.php manually and It's may be duplicate of - duplicate
1 ) Open file vender/laravel/framework/src/Illuminate/Routing/Router.php".
2 ) and comment these
// $this->get('password/confirm', 'Auth\ConfirmPasswordController#showConfirmForm')->name('password.confirm');
// $this->post('password/confirm', 'Auth\ConfirmPasswordController#confirm');

Laravel pdf issue: failed to open stream: No such file or directory by using barryvdh/laravel-dompdf package

I am update composer and use barryvdh/laravel-dompdf package.
the problem is when i click the button it show me error like image below:-
Is that anyway to change the folder path? or am I missing code to modify path to download the pdf file?
You need to run this command:
php artisan vendor:publish
Then, try to create a fonts directory in the storage directory.
i.e. storage/app/fonts. Also, remember to make it writable.
For maximum execution time of 30 seconds exceeded, this is not laravel related issue but it's about php configuration issue. Please see this and fix it: http://php.net/manual/en/info.configuration.php#ini.max-execution-time
You can also see this answer: https://stackoverflow.com/a/30290770/6000629
Hope this will helps you!
Try this:
$pdf = PDF::loadView('pdf/personalpdf', compact('user','result'))->setOptions(['defaultFont' => 'sans-serif']);
It worked for me, I didn't make any file/folder
Just remove the reference to css external file in your cart.placeOrder.blade
Note: This directory must exist and be writable by the webserver process.
under the config file thats what it say: therefore you should create the fonts directory inside the storage.
"font_cache" => storage_path('fonts/'),

View [layouts.app] not found in laravel

I have created an application in laravel using appzcoder crud-generator plug-in. i have done everything accordingly but i am getting the above mentioned error. I have a folder named layouts in views folder and this folder has app.stub in it. but when i run the project it gives the following error
View [layouts.app] not found. (View:C:\wamp64\www\myProject\resources\views\admin\items\index.blade.php)
make sure you have run below code if not run it will create layout.app path
or manually create view/layout/app.php
php artisan vendor:publish --provider="Appzcoder\CrudGenerator\CrudGeneratorServiceProvider"

Undefined class Route (Laravel in PhpStorm)

How can I fix this alert in PhpStorm?
And also how to get autocompletion for Route and other Facades?
Check the Laracasts walkthrough
1) Go to: https://github.com/barryvdh/laravel-ide-helper
2) Click on the gist
Generated version for L5: https://gist.github.com/barryvdh/5227822
3) Click on "Raw" to get the current version (as of June 22, 2016 it is):
https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
4) Make sure you're in your root directory (this is mine)
cd /var/www/html/project
5) Download the gist:
wget https://gist.githubusercontent.com/barryvdh/5227822/raw/4d4b0ca26055fa4753b38edeb94fad2396c497c0/_ide_helper.php
6) Add "_ide_helper.php" to the .gitignore file
sudo nano .gitignore
Add "_ide_helper.php" on a new line at the bottom
7) Download the .gitignore and _ide_helper.php files into PhpStorm
This is what my PhpStorm project directory looks like afterwards:
8) After the files are downloaded into PhpStorm, the "Undefined class" error will disappear and autocompletion will now work. Might need to restart it.
There is greate IDE support for Laravel shipped from Baryvdh:
https://github.com/barryvdh/laravel-ide-helper
after you install it you just call in the console:
php artisan ide-helper:generate
which generate alll facede shortcuts in _ide_helper.php file (which you have to exclude from git)
There is also something special for PhpStorm:
php artisan ide-helper:meta
which will give Laravel container context for example:
$foo = app(Foo::class);
PhpStorm will know that the $foo variable is type of Foo class.
I know this is an old thread, but it is still relevant. For me, I decided to add the following to my routes/web.php since I don't want to have to worry about regenerating meta data for the app.
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
Edit: The above does not add any overhead to PHP as the use simply acts as a reference for PHP.
I solved this problem simply by installing the Laravel idea plugin.
Use the following link:
https://laravel-idea.com/
You can install it on your phpstorm.
Its good feature is that you can use it for 30 days for free and pay the amount after satisfaction.

Laravel 5.1 rename project

What is the best solution if I want to rename my laravel 5.1 project, I just tried to rename one but it did not work properly got some errors.
Are there some kind of steps one has to do to rename a laravel project?
You should use php artisan app:name command to rename your app. It will change namespace in all project files for you. This is the only right way to rename your app.
https://laravel.com/docs/5.0/configuration#after-installation
From laravel version 5.3^ there is a function to call the app name
config('app.name');
You can change the default name 'Laravel' inside this file
config/app.php
'name' => 'Laravel',
And also inside .env file
APP_NAME=Laravel
I just recommend to:
go to .env file at APP-NAME =
put your desired name in "" (double quotes)
restart your server
And you're done.
You can change your project name using the following command:
php artisan app:name your_git_name\your_app_name

Resources