Questions tagged [autoload]
autoload is a language convention which allows missing classes or method dependencies to be loaded on-demand.
1,889
questions
-1
votes
1answer
22 views
Wordpress/PHP - Namespaces/Autoloader - Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($function) must be a valid callback
I am creating my first plugin entirely from scratch. Whenever I try to add a namespace to the 'template-plugin-activate.php' file, I get the following error:
Plugin could not be activated because it ...
0
votes
1answer
24 views
Cannot autoload class using composer from within other autoloaded class file
I'm new to using composer for autoloading custom class files using 'PSR-0' way of autoloading classes.
Below is my directory tree structure.
And below is my PSR-0 config in the composer.json file
...
0
votes
0answers
8 views
are there any side effect of importing too many classes in the controller or some other class?
I am just curious to know what is the trade off in organizing our Laravel/php code in repository pattern?
Sure that might make the development and maintenance of the code super easy but is there ...
1
vote
0answers
24 views
Rails 6 doesn't load engine modules and classes (Zeitwerk?)
At work, we both have an Rails application 'MyApplication' and an gem/ engine 'MyEngine' which provides utilities to MyApplication. One of the purposes of MyEngine is to monkey patch ruby base classes ...
0
votes
0answers
16 views
Custom exceptions management vs PSR-4
I'm improving my PHP level, and turn my classes management into my app in order to use namespaces and PSR-4 autoloading with composer.
But I have question related to custom exception.
At the begining ...
0
votes
0answers
51 views
Problem with Active Model Serializer auto-reloading after changed files in Rails 6
I've created a file in the subfolder app/decorators
# app/models/document.rb
class Document < ApplicationRecord
def url
# ...
end
end
and defined serializer:
class DocumentSerializer < ...
0
votes
1answer
30 views
PHP autoload not working in subdirectory but works in root directory [duplicate]
I am trying to use namespaces and autoload in my PHP project. So I have
require('classes/autoload.php');
in the root directory which works but in my subdirectory I have
require('../classes/autoload....
0
votes
0answers
21 views
PSR-4 Composer Autoloading won't find my new classes [duplicate]
I'm trying to leverage Composer's PSR-4 autoloading, but it's not working for me. I'm 90% confident I have my casing correct :D but I'm not sure what else could be causing my problems. I have ran ...
0
votes
0answers
57 views
Doctrine 2: The annotation was never imported. Did you maybe forget to add a “use” statement for this annotation?
I've upgraded my Laravel/Doctrine application from from 5.4/~1 to 8.25/2.12 on PHP 7.4 after a long time and I feel like I missed some memo. I get that AnnotationRegistry is deprecated and now we ...
0
votes
1answer
76 views
Spark Cloudfiles Autoloader BlobStorage Azure java.io.IOException: Attempted read from closed stream
I learn to use the new autoloader streaming method on SPARK 3 and I have this issue.
Here i'm trying to listen simple json files but my stream never start.
My code (creds removed) :
from pyspark.sql....
1
vote
2answers
43 views
PHP autoload with namespaces do not load file
I have an issue with my autoloader and namespaces.
Below the autoloader
<?php
spl_autoload_register( function( $class ) {
$folder = 'include/';
$prefix = 'class.';
$ext = '.php';
...
0
votes
1answer
92 views
How to apply the “auto next post load” scroll on my website?
A newbie here...I am trying to apply a system that allows readers to "infinitely" scroll down to the next posts after finishing a single post so that they don't have to manually click them.
(...
1
vote
0answers
23 views
Using Zend Framework 1 library in Laminas API tools - auto loading vendor prefix class
I am working on a Laminas API tools (version 1.4) project. There is ZF1 library which I need in my code. the structure of library is:
DirectoryA
.DirectoryB
file1.php =====> ...
0
votes
0answers
23 views
Composer autoload in own package / class not found
I've tried now some different approaches and read articles here and elsewhere but i can't figure out what i'm doing wrong.
I'm developing a package and I want it to be installed via symlink in a ...
0
votes
0answers
30 views
PHP - spl_autoload lowercasing class names
I'm trying to use spl_autoload() to autoload namespaced classes, where the folder structure follows namespaces, without implementing my own autoloader. I've followed this comment on the manual. ...
1
vote
0answers
31 views
Autoload Class not found
I can't seem to figure out why i keep getting this error even though everything seems correct.
My Composer.json looks like this:
{
"autoload": {
"psr-4": {
...
1
vote
1answer
48 views
Why am I getting error Class not found even if the class does exist and is correctly namespaced
I am trying to develop a package with will be required by some of our applications. However, I am unable to test the package when I require it using composer inside an application.
The package has the ...
0
votes
1answer
32 views
Getting “Class not found in” on production but not on local or dev server
UPDATE 1:
After finding out the issue lies with the order in which the plugins are loaded, I am left with the question why the plugin load order changed between 2 dev servers and even between the ...
0
votes
1answer
27 views
Composer autoload error while uploading laravel 7 app on VPS server [closed]
I have my Laravel 7 app uploaded on VPS server running on subdomain. Everything is fine, index.php opens for the subdomain, I have generated app key and installed composer packages.
Then I got 500 ...
0
votes
0answers
30 views
Problem with PHP autoload
I am trying to use autoload to load a class on a file but it keeps giving me this error warning message below. What can I do differently ?
The code on the autoload file is:
<?php
function ...
0
votes
1answer
38 views
How to access packages in vendor directory
Calling any package from the vendor directory structure within any CakePHP controller works, as the composer set up everything correctly. For example this MCVE from https://github.com/giggsey/...
0
votes
0answers
14 views
Why there is no autoloading for functions? [duplicate]
As is well known, in modern PHP we can use autoloading for classes.
I wonder why such feature isn't implemented for standalone functions under a namespace?
Why automatic loading a class, say,
...
1
vote
0answers
237 views
Using Google Spreadsheet API without composer : how to make it work?
I'm having an issue for 3 days using Google Spreadsheet API on my FTP server.
OVH serv does not permit to install of Composer so I am trying to get it without this tool.
I tried several things but so ...
1
vote
1answer
216 views
Why does Mac OSX still exhibit case insensitivity when using Docker Desktop for Mac
I am using Docker Desktop for Mac to containerize a basic LAMP stack in my local environment, then periodically deploying a simple MVC application to a shared Linux server using a Bitbucket pipeline.
...
4
votes
1answer
577 views
“Unable to autoload constant” Bug in Rails 5.2.0
I'm running a Rails 5.2.0 application. This LoadError always appears on the first request after a reboot or a recompile:
Unable to autoload constant Api::V1::ApplesController, expected /...
1
vote
1answer
56 views
Autoloading Problem in Object-Oriented PHP Program
Good afternoon to everyone.
For the past 3 days, I've been struggling with PHP's Autoloading features, which aims to simplify and unify a program's class files, all located in one executing file. For ...
0
votes
1answer
51 views
PHP autoloading classes/subclasses
I'm brand new to PHP. To jump right into it, I have a Person class, a Customer class that extends Person, and a Basic Class that extends Customer. I also have a Book class (it's a Bookstore project) ...
0
votes
0answers
113 views
Codeception Unit test class does not comply with psr-4 autoloading standard in Laravel App [duplicate]
This is my composer.json file:
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"...
1
vote
1answer
59 views
Why Codeignitor does not accept autoload Controller classes when validating routes?
Why does Codeignitor not accept Controller in composer autoload when validating routes?
It's checking by: class_exists($class, FALSE) where the second parameter disables checking in autoload.
https://...
0
votes
0answers
43 views
How to autostart jwplayer when stream start
Hi i would like to know if there is a way to autoload the page, i have a jwplayer that when its off stream have a thumbnail thats ok but i want when the stream starts automatically autoload the page ...
3
votes
1answer
2k views
Deprecation Notice: Class Foo\Bar\Baz located in ./src/foo/bar/Baz.php does not comply with psr-4 autoloading standard
When running composer's update, install, require, dump-autoload, etc.; I suddenly start getting a yellow deprecation notice that says:
Deprecation Notice: Class Foo\Bar\Baz located in ./foo/bar/Baz....
1
vote
1answer
57 views
Composer expected class(but not found) when trying to autoload PHP file
I am trying to autoload just a PHP file without any class in it but with helper functions instead. Something like Laravel helpers so:
<?php
if (!function_exists('fixture')) {
function fixture()...
0
votes
0answers
15 views
Does Rails autoload have anything to do with Paths::Root?
when Rails requires one of its modules, the file /module_name/lib/module_name.rb is loaded. This file regularly employs ActiveSupport::Autoload in order to a) autoload and b) eager_load Constants of ...
0
votes
0answers
49 views
PHP spl_autoload_register not working with use funciton import
When using spl_autoload_register, an imported function via use function Namespace\Subamespace\aFunc php cannot find the function. The registered autolaod function is not invoked. If I manually include ...
0
votes
1answer
29 views
opentok php sdk undefined variable streamId [duplicate]
Notice: Undefined variable: streamId in C:\xampp\htdocs\vonagephp\index.php on line 46
This is the problem. I hope someone can help me.
I am creating a opentok video using the php sdk but I have come ...
1
vote
0answers
42 views
Laravel - create a local copy of package with composer repositories feature
The previous company which worked on the project is using their own package for the admin panel.
I want to have total control over it.
I tried the following:
I created a packages folder in the root ...
1
vote
0answers
63 views
Web-push-php throwing Class not found exception
So I'm trying to set-up the push-notification service in PHP, and I'm using the web-push-php library from MinishLink. But for some unknown reason (to me) its throwing me Class 'Minishlink\WebPush\...
-2
votes
1answer
40 views
Load Legacy PrestaShop classes from deploy.php file
From deploy.php file in the root of my Prestashop project I call a method
ModuleManagerBuilder::getInstance();
that in turn calls other Legacy Prestashop classes like Configuration
This throw an ...
1
vote
2answers
667 views
Rails 6 not auto-loading class properly in development (zeitwerk mode)
My understanding is that Rails is able to auto-load classes properly named within the app folder, by default.
It's not happening for me, so I want to see if you can find an obvious issue with my code.
...
0
votes
0answers
334 views
Using Namespaces and autoloader in PHP 7.4
I'm kinda confused on how Namespaces work with Autoload. I'm currently trying to learn PHP 7.4 and I came to the point where I wanted to learn how to use Namespaces and an Autoloader for the classes.
...
3
votes
1answer
697 views
Laravel routing cache
When I develop a Laravel application I used to clear cache after making any changes to routes\web.php or routes\api.php. Recently I was working on a project for a fellow and found out that the project ...
0
votes
0answers
16 views
How do I find all autoloaded classes that implements an defined interface in PHP?
I'm trying to create my first own package.
In the package I've define an interface.
I've created multiple implementations of the interface myself. But the idea is that the user can create his own ...
1
vote
2answers
52 views
Autoloading php classes not found
I'm autoloading classes in my php file, and the autoloaded can locate and require the file with no problem. However, when I then go to use the class in my code, I get the error "Class not found&...
2
votes
2answers
216 views
MVC using composer autoload psr-4 is not worked for me
I'm trying to create a MVC structure and use composer to autoload everything.
But I keep getting this error:
<b>Fatal error</b>: Uncaught Error: Class 'App\Core\Main' not found in /var/www/...
0
votes
1answer
79 views
Use an external repository with symfony4 trouble with autoload and parameters
I use two self developed libraries located in github as a private repository so I can reuse it in several projects. I include them via composer:
"license": "proprietary",
"...
0
votes
0answers
43 views
Problem with PSR-4 Autoloader using composer
I have this directories structure:
src
- PrintXMLInfo.php
- PrintListInfo.php
- PrintInformation.php
vendor
main.php
composer.json
Now in composer.json I declared this psr-4 ...
1
vote
1answer
163 views
Autoloading a custom package in Laravel7
Sorry if my question looks so basic...
Am trying to use the following package in a fresh Laravel7 installation.
https://github.com/phpclassic/php-shopify
As like they mentioned i used 'composer ...
0
votes
1answer
57 views
Rails custom project structure autoloading configs
I have a standard app that contains of sub-apps that we will slowly migrate into separate gems. The main problem is that each sub-app basically has an almost identical schema and very similar business ...
-2
votes
1answer
145 views
How does composer know which classes are used? [duplicate]
I was wondering how Composer knows which classes are used in the scripts that will be executed. Does PHP provide a hooking mechanism with a callback? I'm guessing it's not inspecting the code since ...
0
votes
1answer
67 views
Functional Tests with TYPO3 v10 no composer autoload
When I try to run a functional test which uses the class TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase I get an error Class 'TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\...