Questions tagged as 'php-autoload'

5
answers

Optimize function to include classes also looking in sub-directories

I have the following function to include classes when we are trying to use a class that has not yet been defined: /** * Attempt to load undefined class * @param object $class_name object class name */ function __autoload($class_name) {...
asked by 16.01.2014 / 16:40
2
answers

What are the differences between __autoload and spl_autoload_register?

In php, we have two methods of doing autoload of classes: function __autoload Example: function __autoload($class_name) { require_once $class_name . '.php'; } $obj = new MyClass1(); $obj2 = new MyClass2(); function spl_au...
asked by 16.07.2015 / 17:29
1
answer

Error 'use' (T_USE) when using autoload

I have the following folder and file structure: -api -v1 -libs -Slim -Facebook -autoload.php -index.php -login.php Inside the "index.php" I include the "login.php" include: require_once 'login.php'; In the "login....
asked by 17.02.2015 / 19:54
1
answer

How does [modus operandi] autoload work in PHP?

Suppose I have the following file structure in the root of my site: index.php autoload.php ----| /Models --------| /MainModel ------------| MainModel.php ----| /Controllers --------| /MainController ------------| MainController.php Suppos...
asked by 04.01.2017 / 20:42
1
answer

"New" autoload PHP 7

I would like to understand the "new" autoload of PHP, in it I can choose the name I want to put? For example, in the old one, it was __autoload . In this case, can I put autoload_de_teste ? Another question is what does the spl...
asked by 30.10.2017 / 17:17
1
answer

Autoload class PSR4

I would like to create a autoload class that follows the PSR4 recommendations and can be used independently of the Composer autoload >. The application I'm creating will have the following structure: /root |--/src...
asked by 08.10.2015 / 23:26
1
answer

Composer Autoload does not work?

I'm trying to use autoload of composer and I can not, it says that the not found class is trying to load a class from an external library. I've already run the command line: composer install and composer dump u...
asked by 15.06.2017 / 17:39
0
answers

Autoloading does not recognize use command, after a submit?

<?php namespace App\Controller; class Action { function mostrarDado(){ echo "Mostrando Dados...."; } } <?php $paramUser = $_GET['usuario']; $paramSenha = $_GET['senha']; var_dump($paramUser); v...
asked by 15.10.2018 / 15:02
1
answer

Configure Namespace and autoload PSR-0

I am developing a project with the following structure: Thegoalistomakeautoloadloadtheclasses.Theautoload.phpfile:functionautoload($className){$className=ltrim($className,'\');$fileName='';$namespace='';if($lastNsPos=strrpos($className,'\')){$n...
asked by 11.10.2016 / 14:21
1
answer

Doubt about autoload php

About autoload I studied about: Autoload for classes in the same folder function __autoload($nomeClass) { require_once ("$nomeClass.php"); } Autoload for classes in specific folders spl_autoload_register(function ($nomeClass) { if...
asked by 03.01.2018 / 14:14