mardi 28 janvier 2020

PHP spl_autload_register alternative way

I am making a pattern for my own project, We knew that this spl_autoload_register turn into all files until it finished. It just returns the class as I know. Let's get into my wish/ Problem.

app
 |__ controllers
 |      |__ ctrl-default.php
 |      |__ ctrl-other.php
 |
 |
 index.php

In my controllers have classes with the almost same name.

// ctrl-default.php
class  ctrl_default{
  //silence is golden...
}

// ctrl-other.php
class  ctrl_other{
  //silence is golden...
}

I can not find the class name for the '-' and '_' But I don't want to change my file name or class name. Is there any possible way to get all the class on my index.php page, without changing the controllers' name? Is there any alternative way of spl_autoload_register()?

Aucun commentaire:

Enregistrer un commentaire