Reputation: 3819
In one of my "Elements" I'd like to use the Inflector
class, but it always shows
Fatal error: Inflector class not found.
How do I include this class in cake way in my view files?
I tried to add use Cake\Utility
and use Cake\Utility\Inflector
, but neither of them helped.
Upvotes: 2
Views: 2416
Reputation: 118
Try this one
\Cake\Utility\Inflector::humanize('Inflector working in the view')
fully qualified namespace from anywhere like Model, View or Controller
Note: Do no forget to use "\" at the start!
Upvotes: 5
Reputation: 183
You can just fully qualify the inflector class methods i.e. Cake\Utility\Inflector::method()
e.g.
<?= Cake\Utility\Inflector::humanize('Inflector working in the view') ?>
OR
You can just create a custom helper class, use the Inflector class there and then call the custom helper method in your view.
Upvotes: 1