Controllers in MightyPHP are stored in Application/Controller folder. A typical controller would like this:

namespace Application\Controllers;
use Application\Controllers\Controller;
use MightyCore\Http\Request;
class FooController extends Controller
public function bar(Request $request){
return 'Hello World';

Controllers will be where your application logic lives. The good practice would be not to get your controllers too long or complexed. You may want to offload some reusable codes to Services, in order for your codes to be DRY.

Generating Controllers

To increase productivity, MightyPHP comes with a boilerplate generator that helps you to set up quick. In order to generate a controller boilerplate, simply run this command:

php mighty make:controller HelloWorld

All generated controllers will move into Application/Controllers.