Laravel 5 make:controller creating controller in app folder instead of controller folder
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Understanding Laravel 5's Controller Creation Process and Troubleshooting Issues
Introduction: Laravel is a popular PHP framework that simplifies the application development process by providing various tools and features. One such tool is the "make:controller" artisan command, which generates a new controller class for your application in Laravel 5. However, you may encounter issues where controllers are created outside of their intended directory, specifically in the root of the app folder instead of its designated folder. In this blog post, we'll cover why this happens and provide tips to solve the problem.
Problem: As a beginner Laravel developer, your understanding of the framework can impact how you use its various tools. You may find yourself facing an issue where your controllers are being created in the root of the "app" folder instead of the "controller" folder. This might be frustrating and make it more difficult to locate and manage them efficiently.
Solution: The laravel company provides comprehensive documentation on using artisan commands, including the controller creation process. To address your issue, follow these steps:
1. Ensure you are using the correct directory structure for creating your application. Laravel's file and folder organization is designed to optimize code management and accessibility. Make sure "app" and all its subfolders exist as per the framework guidelines.
2. Check your artisan command syntax. The command used,
php artisan make:controller PagesController, appears correct at first glance. However, it is essential to review the actual path of the controller being created in case of any potential differences between your actual and expected directory structure.
3. Verify your laravel/laravel git repository's version. Download the latest Laravel framework from its official website or update your existing installation if you are using a customized package manager to ensure compatibility with current features, including artisan commands.
4. Clear your project cache and config files. The problem could be caused by outdated data or configuration issues. To resolve this, run the following command: php artisan cache:clear && php artisan config:clear. This will clear all caches and config files, ensuring you work with fresh information.
5. Check your gitbash environment. If using windows, ensure that your Git Bash is set up correctly to recognize the correct path separators (forward slashes /) for Laravel's file system. You can also try running the command in a different terminal emulator to see if it resolves the issue.
Conclusion: Understanding and troubleshooting issues with artisan commands, including the controller creation process, is crucial to maintaining an efficient Laravel development environment. By following these guidelines and best practices, you can create and manage your controllers more effectively in their intended directory.
Remember, when encountering problems like this in your Laravel projects, it's best to seek support from reputable resources like the official documentation or community forums to ensure consistency and compatibility with the framework. Happy coding!