CI4 Model Is huge |
I'm facing an Issue in my CI4 project,
I override the mode returnType to be self::class [To handle the relation between the models] When I'm trying to var_dump the model, I got a huge object contains the AutoLoad, FileLocator, .. etc Which causes a Memory Limit error How can I fix it?
Your server seems to have too little RAM.
(09-03-2023, 03:22 AM)ozornick Wrote: Your server seems to have too little RAM. No, It's 16GB ram, I'm talking about the model object, why it has the autoloader classes? The issue occurred after I installed the google-sdk which has a lot of classes, so now when var_dump the model, I'll see all autoloaded classes!
Try d($model) from Kint package
Or install Code: composer require --dev symfony/var-dumper Add functions dump() and dd()
This is the default Model object. It is not small, but does not have AutoLoad, FileLocator.
Code: .../CodeIgniter4/app/Controllers/Home.php:12:
@Mazen Yep, if you use PSR4 autoload, this is what you should expect. If I am not mistaken, at an earlier time something like this happened, so bear this in mind if you play with the module Take care: How do you organize your class and methods?
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
Ah, there is CodeIgniter\Autoloader\FileLocator in CodeIgniter\View\View in CodeIgniter\Validation\Validation.
I seem to have overlooked it. Code: protected 'validation' => (09-05-2023, 07:05 AM)luckmoshy Wrote: @Mazen Yep, if you use PSR4 autoload, this is what you should expect. If I am not mistaken, at an earlier time something like this happened, so bear this in mind if you play with the module Take care: How do you organize your class and methods? All my relations is inside the model, so once I find any model I need the returnType to be self::class For Example: class User extends Model { public function posts() { return (new Post())->where(['user_id' => $this->id])->findAll(); } } So I decided to skip model validation and set the validation object to null as following $this->validation = null; $this->skipValidation(); and move all validation rules to the requests classes by using Service::validation()->run($data) instead of using $model->validate($data); |
Welcome Guest, Not a member yet? Register Sign In |