Hi guys,
I am trying to get the class attributes for each model class in my application. My model classes extends yii\db\ActiveRecord and have been created via gii. So What I am trying to get is the model attributes same when you use $object->attributes() but with a class name instead of a class object that’s why I am using php reflection class -> get property. The problem is I am getting an empty array.
Question 1: How to get class attributes using class name (full with path/name space)?
Question 2: Is there a way to get the class attributes with class shortname only? Note: I am not repeating class names so there should not be any conflict from having similar class names on different paths.
Here is a copy of example code:
$r=new reflectionClass(‘app\modules\EM\models\Role’);
//Role is a model class in my application
$array=$r->getProperties();
//$array comes back empty…
The role class has the following attributes
id
title
description