CakePHP Helper謫堺ス

繝倥Ν繝代シ縺ィ縺ッ

繝薙Η繝シ縺九i蛻ゥ逕ィ縺吶k蜈ア騾壼ヲ逅
迚ケ螳壹ョ繝薙Η繝シ縺ォ髯仙ョ壹@縺ェ縺蜃ヲ逅繧定ィ倩ソー縺励∝ィ縺ヲ縺ョ繝薙Η繝シ縺九i蛻ゥ逕ィ縺ァ縺阪k

繝倥Ν繝代シ縺ョ菴懈

繝倥Ν繝代シ

窶サス杤src\View\Helper\UtilHelper.php
<?php
namespace App\View\Helper;

use Cake\View\Helper;

class UtilHelper extends Helper {
public function initialize(array $config){
縲縲parent::initialize($config);
縲}

縲public function getText(){
縲縲return 'aaa';
縲}
}

繝倥Ν繝代シ縺ョ繝ュ繝シ繝

窶サス杤src\View\AppView.php
class AppView extends View{
縲public function initialize()
縲{
縲縲$this->loadHelper('Util');
縲}
}

繝倥Ν繝代シ縺ョ蛻ゥ逕ィ

View

窶サス杤src\Template\(繧ウ繝ウ繝医Ο繝シ繝ゥ蜷)\ス.ctp
<?php
縲echo $this->Util->getText();
?>

Follow me!