FAQ Database Discussion Community


How to call this function for every controller in codeigniter

php,codeigniter,controller,autoloader
My situation is that, I have 20 controllers in my website, where I have a function like this. $this->lang->load("main", $this->session->userdata("lang_code")); How can I load this function in all the 20 controllers without adding it individually to the __constructor of every controller?...

Load git repo with composer - autoloading issue

php,git,composer-php,autoloader
I have a github repository https://github.com/KoulSlou/UPS and I would like to add it to my project. In project root I created composer.json file and defined the following autoloading properties: { "autoload": { "files": [ "libraries/Ups/Ups.php", "libraries/Ups/Ups_Base.php", "libraries/Ups/Ups_Base_Response.php", "libraries/Ups/Ups_Live_Rates.php" ] } } When I run php composer.phar install repository is being...

Will PHP Autoloader load when calling a class constant?

php,autoloader
I have a class that defines some class constants. It looks something like this phony class for simplicity. class MyThing { const BORIS = 'Yeltsin'; } I'm registering the directory that the class is located like so. AutoLoader::registerDirectory('lib'); I'm using PHP's autoloader and it works as expected, except when I'm...

PHP Composer Autoloader Simple Structure

php,composer-php,autoloader,psr-4
I have Composer working and I'd like to use its autoloader to load my classes, but it's not working. Here's my directory structure. I'm keeping it really simple to start with. index.php composer.json Vendor controllers/webgl.php Inside webgl.php I have: namespace controllers; class webgl { public function lesson1() { } }...

Zend 1 3d party NameSpaces autoload don't working

php,zend-framework,amazon-web-services,namespaces,autoloader
I'm trying to implement Amazon WebServices PHP SDK into my Zend 1 project, but it seems to fail loading the classes. I have got the library into library/Eplan/AmazonCloudSearch and after investigation it seems that in order to be able to load the namespace I need to call the registerNamespace method...

spl_autoloader not loading any classes

php,namespaces,autoloader,spl-autoload-register,spl-autoloader
so i've started using namespaces and read some docs but I seem to be doing something wrong. First off is my application structure which is build like this: root -dashboard(this is where i want to use the autoloader) -index.php --config(includes the autoloader) --WePack(package) ---src(includes all my classes) now in the...

How to load PHP config files with an autoloader

php,oop,autoloader
I have a project of legacy code that I've nearly successfully converted to use an autoloader rather than a bazillion include and require statements. The only remaining issue that I have is a config file that sets up some global config stuff. As it is now, it's just a straight...

PHP autoloader class to load files from two or three different path

php,autoloader
I'm learning to use php autuoloader... As much as I understand, we can use __autoloader or spl_autoloader_* to auto load files. Assume this is my directories structure : ROOT | | ADMIN | | | | | DIST | | | SOME_FOLDER | SOME_FOLDER | TPL | | | |...

Is module auto-loading meant to be reliable?

powershell,module,autoloader
Environment I have the following folder structure where I keep powershell modules: C: PsModules ... util util.psm1 (this contains implementation of 'Test-Function') util.test.ps1 ftp ftp.psm1 http.test.ps1 ... There are about 50 folders and modules in c:\PsModules. I have set environment variable PSModulePath to include c:\PsModules. This seems to meet the...

Swift Mailer ruins autolading

php,autoload,swiftmailer,autoloader
I'm writing simple PHP application which is using Swift Mailer library. My app doesn't use namespaces nor composer. However, after requiring swift_required.php my (model) classes are not found (Fatal error: Class 'Format' not found is thrown by PHP interpret). Autolading define("_DOCUMENT_ROOT", str_replace("//", "/", $_SERVER['DOCUMENT_ROOT'] . "/")); function __autoload($class_name) { $file_name...

Composer for autoloading php

php,composer-php,autoloader
Hi i have this folder structure: I'm using composer for autoloading my files but it is dont work .. i do it first time and i dont know how to implement this. My composer.json { "name": "Some name", "description": "Some Framework", "minimum-stability": "stable", "license": "proprietary", "authors": [ { "name": "Some...

phalcon load classes from directory

php,model-view-controller,model,phalcon,autoloader
I have a problem with loading "Model" classes from directory in phalcon framework 2.0. I can't use namespaces now, because project is migrating step by step from ZF1, and Model classes has many dependencies with themselves. If I register namespaces for every directory - loader works great, but I need...

How autoloader works in zend framework 2

php,zend-framework2,package,composer-php,autoloader
I am just trying to create a package for packagist, a zend framework 2 user authentication module, https://packagist.org/packages/tahmina8765/zf2auth When I keep this zf2auth folder in my modules folder, it works. But when I download it with composer, it downloaded in vendor/tahmina8765/zf2auth. In this folder, it does not work. I mean,...