autoloader

How to create a PSR-4 autoloader for my project?

假如想象 提交于 2021-01-28 03:06:17
问题 I am creating a PHP project and want to implement PSR-4 autoloading. I don't know which files I need to create in the vendor directory to implement autoloading for class files. 回答1: If you are using composer , you do not create the autoloader but let composer do its job and create it for you. The only thing you need to do is create the appropriate configuration on composer.json and execute composer dump-autoload . E.g.: { "autoload": { "psr-4": {"App\\": "src/"} } } By doing the above, if you

Class Firebase\JWT\JWT not found

安稳与你 提交于 2020-06-08 16:44:20
问题 I want to use pure firebase/php-jwt library in my code. Firstly, I go to /var/www/html/ and like the official library page is suggesting, I do this composer require firebase/php-jwt After I run this command, I see that a new vendor folder is created inside /var/www/html/ with a lot of files and subfolders. I then create my token.php file right in /var/www/html/ with contents similar to that from the official page: <?php use \Firebase\JWT\JWT; $key = "example_key"; $token = array( "iss" =>

Use Zend_Autoloader for Models

纵饮孤独 提交于 2020-01-23 12:03:22
问题 does someone knows how to use the "new" Zend Autoloader to Load Models ? In the Moment my Configuration looks like this : application.ini # Autoloader Namespace autoloadernamespaces.0 = "Sl_" Bootstrap.php /** * Start Autoloader * * @access protected * @return Zend_Application_Module_Autoloader */ protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Sl_', 'basePath' => dirname(__FILE__), )); return $autoloader; } So when I place a

PHP-intercom not working after updating composer

北城以北 提交于 2020-01-06 16:04:08
问题 i recently updated using composer. After updating I am getting error in php file , where I am sending data to intercom. This is the error : Fatal error: Class 'Intercom\IntercomBasicAuthClient' not found in <filename> I found a similar problem here Symfony Exception (Class not found) only on development and production servers. But couldn't understand exactly how to solve the issue. I tried using intercom in Uppercase as well as lowercase, but problem is not solved. In my installed.json I

PHP-intercom not working after updating composer

你。 提交于 2020-01-06 16:03:52
问题 i recently updated using composer. After updating I am getting error in php file , where I am sending data to intercom. This is the error : Fatal error: Class 'Intercom\IntercomBasicAuthClient' not found in <filename> I found a similar problem here Symfony Exception (Class not found) only on development and production servers. But couldn't understand exactly how to solve the issue. I tried using intercom in Uppercase as well as lowercase, but problem is not solved. In my installed.json I

CodeIgniter autoloaded models' variables are lost after an AJAX call

与世无争的帅哥 提交于 2020-01-06 13:57:49
问题 I've been creating an application that requires buttons to make an ajax call to a controller that uses autoloaded models. I was under the impression that variables in an autoloaded model would retain their values after an Ajax call, but for some reason the entire model (including their variables) have lost their new values. Am I misunderstanding the way the autoload function works, or does it have something to do with me using Ajax? Code for reference below. Autoload: $autoload['model'] =

PHP: How to get all classes when using autoloader

◇◆丶佛笑我妖孽 提交于 2020-01-02 06:33:29
问题 I'm using composer to generate autoloader: "autoload": { "psr-4": { "SomeNamespace\\": "src/SomeDir" } } I need to create instances of all classes that implement specific interface. It's fairly easy when not using autoloader, however get_declared_classes() is not playing well with autoloaders. It will list a class only after it was instantiated with autoloader. 回答1: If you don't keep track of which classes exist, autoloading won't help you. But the situation would be pretty much the same if

Optimize my performance

我是研究僧i 提交于 2020-01-02 03:46:13
问题 I'm working on a project with Zend Framework 1.11, Doctrine 2, some Symfony 2 componenents and others tools & libraries. I'm trying to optimize performance using Xdebug & Webgrind. I've already found some bottlenecks like parsing Ini config, etc.. and cached that. Now, I just realize that the autoloading is the most costly part of my application: Opl\Autoloader\ApcLoader->loadClass 274 31.36 43.86 Zend_Loader_PluginLoader->load 150 4.80 12.29 Zend_Loader_Autoloader->getClassAutoloaders 278 1

Fatal error in Autoloader.php on line 34 phpExcel

别来无恙 提交于 2020-01-01 10:53:11
问题 I want to use phpExcel, but when run the script I get this error: Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Multibyte function overloading in PHP must be disabled for string functions (2).' in D:\Apache\htdocs\phpExcel\Classes\PHPExcel\Autoloader.php:34 Stack trace: #0 D:\Apache\htdocs\phpExcel\Classes\PHPExcel.php(32): require() #1 D:\Apache\htdocs\phpExcel\index.php(19): include('D:\Apache\htdoc...') #2 {main} thrown in D:\Apache\htdocs\phpExcel\Classes\PHPExcel

Class not found PHP OOP

江枫思渺然 提交于 2019-12-25 08:53:11
问题 I can't get this to work. <?php function __autoload($classname){ include 'inc/classes/' . $classname . '.class.php'; } __autoload("queries") $travel = new queries(); echo $travel->getPar("price"); ?> And this is the inc/classes/queries.class.php file. <? class queries { function getPar($par, $table='travel', $type='select') { $result = $db->query(" $type * FROM $table WHERE $par LIKE "); while ($row = $result->fetch_assoc()) { return " $row[$par] "; } } } ?> It returns "Class 'queries' not