Skip to content

Instantly share code, notes, and snippets.

@miftahafina miftahafina/console.php

Last active May 14, 2020
Embed
What would you like to do?
Remove laravel controller with artisan command
<?php
/**
* Copy and paste the code below into your routes/console.php file.
* You can add more command such as 'remove:model', 'remove:middleware', etc if you want,
* just modify the $file_location variable.
*/
Artisan::command('remove:controller {name : Name of the controller}', function ($name) {
// File location
$file_location = base_path() . '/app/Http/Controllers/' . $name . '.php';
// Check if exist
if (file_exists($file_location)) {
exec('rm ' . $file_location);
$this->info($name.' has been deleted!');
} else {
$this->error('Cannot delete ' . $name . ', file not found.');
}
})->describe('Remove spesific controller');
@undefinedzain

This comment has been minimized.

Copy link

undefinedzain commented Aug 23, 2016

Lha tujuan nya hapus controller apa ? :)

@miftahafina

This comment has been minimized.

Copy link
Owner Author

miftahafina commented Aug 23, 2016

@zera272 tujuannya biar anu... pas typo generate controllernya. Rare banget sih, emang. 😆

@mdmunir

This comment has been minimized.

Copy link

mdmunir commented Aug 23, 2016

👍

@jawircodes

This comment has been minimized.

Copy link

jawircodes commented Jun 3, 2017

dihapus manul bisa kan ya?? takutnya klo hapus mnual ada system yg cacad.. :D work tapi mantap lah:v

@shohanean

This comment has been minimized.

Copy link

shohanean commented Mar 4, 2018

Thanks a ton!

@elhakimdev

This comment has been minimized.

Copy link

elhakimdev commented May 12, 2020

'rm' is nit recoginzed as an internal or external command

@miftahafina

This comment has been minimized.

Copy link
Owner Author

miftahafina commented May 14, 2020

@elhakimdev are you using linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.