Codeigniter 4🔥 [07.- helper y basecontroller]
En este tutorial vamos a trabajar con los helpers y ademas vamos a hacer un sencillo ejemplo con basecontroller, por si no recuerdan en este video lo explico: https://youtu.be/cd1FEz-KXNs
La sorpres es que vamos a usar ambos en este tutorial osea los helpers y los basecontroller.
Codigo github.com: https://github.com/programadornovato/codeigniter4/commit/8b753507ee7510d2fc748ca94a18a105666e4aa5
///app/Views/estructura/body.php <body> Hola mundo desde programadornovato.com <?php echo resta(2,1); ?> </body> </html> ///app/Controllers/BaseController.php <?php namespace App\Controllers; /** * Class BaseController * * BaseController provides a convenient place for loading components * and performing functions that are needed by all your controllers. * Extend this class in any new controllers: * class Home extends BaseController * * For security be sure to declare any new methods as protected or private. * * @package CodeIgniter */ use CodeIgniter\Controller; class BaseController extends Controller { /** * An array of helpers to be loaded automatically upon * class instantiation. These helpers will be available * to all other controllers that extend BaseController. * * @var array */ protected $helpers = [ ]; /** * Constructor. * */ public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger) { // Do Not Edit This Line parent::initController($request, $response, $logger); helper('operaciones'); //-------------------------------------------------------------------- // Preload any models, libraries, etc, here. //-------------------------------------------------------------------- // E.g.: // $this->session = \Config\Services::session(); } } ///app/Helpers/operaciones_helper.php <?php function suma($val1,$val2){ return $val1+$val2; } function resta($val1,$val2){ return $val1-$val2; }
Guia de codeigniter 4: https://codeigniter4.github.io/userguide/models/model.html #Codeigniter4 #php7 #backend #Codeigniter #php .
? Esta lista de reproducción: https://www.youtube.com/playlist?list=PLCTD_CpMeEKTFN5TDeOP-wP_hU0_9VoWg
.
Codigos en gdrive: https://drive.google.com/file/d/1awbG6jI40IO0N68fgjLUwNFpsTC3wIHj/view?usp=sharing .
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true .
? Facebook: https://facebook.com/ProgramadorNovatoOficial
? Twitter: https://twitter.com/programadornova
? Linkedin: https://www.linkedin.com/in/programadornovato/
? Instagram: https://www.instagram.com/programadornovato/