-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing Feature: Add initController() by default in php spark make:controller #9465
Comments
No, you don't rewrite |
@samsonasik Is there any reason? I'm also extending |
|
Hello have a look https://codeigniter.com/user_guide/incoming/controllers.html#constructor In the constructor it doesn't even mention anymore __construct() It says to use initController() |
It mention the __construct, that initController called after it. You can add it, but set it by default is not good, as it it is not required. |
@samsonasik I decided to move the initialization from |
It depends of what the usage, yes, |
PHP Version
8.2
CodeIgniter4 Version
4.6.0
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Linux
Which server did you use?
apache
Database
MariaDB 10.8
What happened?
Hello,
I would like to propose an improvement to
php spark make:controller
.Currently, when generating a controller using this command, the initController() method is not included by default.
A similar approach is already taken with php spark make:model, where generated models come pre-populated with useful default settings. I believe applying the same logic to controllers would be beneficial.
Reasons for this change:
Adding this by default would encourage best practices and improve the developer experience.
Let me know your thoughts!
Best regards,
R.
Steps to Reproduce
php spark make:controller
Expected Output
<?php
namespace App\Controllers;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class NomeController extends BaseController
{
// Uncomment and modify as needed
// protected $modelName;
// protected $helpers = ['form', 'url'];
'}`
Anything else?
No response
The text was updated successfully, but these errors were encountered: