Comments (10)
I guess the issue is in the absence of the autoload
section in the composer.json
file.
from cm_redissession.
Thanks @speller - @justinbeaty do you have any additional insight on this, it does appear that an autoload declaration is needed but not sure what your plans were for it exactly.
from cm_redissession.
I guess it could be added, but I don't typically see Magento modules doing this.
If the module is installed with Cotya/magento-composer-installer (or modman, etc) then it is placed into app/code/community
and Magento will find the class. For example:
<?php
define('MAGENTO_ROOT', '/home/www-data/magento-root/htdocs');
require MAGENTO_ROOT . '/app/bootstrap.php';
require_once MAGENTO_ROOT . '/app/Mage.php';
Mage::app();
$c = new Cm_RedisSession_Model_Session();
I think adding an autoloader would be equivalent to adding one to colinmollenhour/Cm_OrderProducts so someone could call new Cm_OrderProducts_Model_System_Config_Source_Filter()
. But what is the point? Unless I am missing something...
Edit: So I think if there's a use-case for a separate entry point like in the OP's 1.php
, why not just bootstrap Magento? Even if we did add an autoload entry I don't think any of the other Mage_
classes would work.
from cm_redissession.
In my case, I'm not using any module managers and use a customized Magento 1 instance that can load backend-only modules directly from the composer directory without copying or symlinking. So I need this package classes to be available for the composer autoloader.
The Cm_Cache_Backend_Redis
module has the autoloader section and it works fine.
from cm_redissession.
Interesting; I’m surprised that works since this module has calls to Mage::app(). But in any case, I don’t think adding an autoload entry would negatively affect an install into OpenMage. If you want to make a PR it sounds like Colin would merge it. I would just double check that having the autoload entry still allows one to override the class via Magento‘s config.xml (which I can also test later today).
from cm_redissession.
I added an autoload entry in my fork and installed via composer justinbeaty@2527c53
The results are that the class can now be loaded with:
<?php
include_once 'vendor/autoload.php';
$c = new \Cm\RedisSession\Model\Session();
But this throws a new error:
$ php test.php
PHP Fatal error: Uncaught Error: Interface 'Zend_Session_SaveHandler_Interface' not found in /home/www-data/magento-root/htdocs/vendor/colinmollenhour/magento-redis-session/app/code/community/Cm/RedisSession/Model/Session.php:32
Stack trace:
#0 /home/www-data/magento-root/htdocs/vendor/composer/ClassLoader.php(478): include()
#1 /home/www-data/magento-root/htdocs/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 /home/www-data/magento-root/htdocs/test.php(5): spl_autoload_call()
#4 {main}
thrown in /home/www-data/magento-root/htdocs/vendor/colinmollenhour/magento-redis-session/app/code/community/Cm/RedisSession/Model/Session.php on line 32
Which is not surprising because the Zend classes do not have autoload entries... Maybe in your customized Magento 1 fork you have autoload entries for those classes too.
So overall I'm not sure this is needed for this repo. Alternatively, could you just define the autoload entry in your own composer.json?
"psr-0": {
"Cm\\RedisSession\\": "vendor/colinmollenhour/magento-redis-session/app/code/community/"
}
from cm_redissession.
But this throws a new error:
The Cm_Cache_Backend_Redis
module has the same issue but it works fine in my case.
So overall I'm not sure this is needed for this repo. Alternatively, could you just define the autoload entry in your own composer.json?
This is a working option, thank you. But as this doesn't break existing package functionality, could you add it to the package repo, please?
from cm_redissession.
I just double-checked the psr-0 solution and found that the $c = new \Cm\RedisSession\Model\Session()
triggers a correct autoloading but the class name is still Cm_RedisSession_Model_Session
and can't be found by PHP. The proper variant is:
"autoload": {
"psr-0": {
"Cm_RedisSession_": "vendor/colinmollenhour/magento-redis-session/app/code/community/"
}
}
This makes the $c = new Cm_RedisSession_Model_Session()
code working fine.
Moreover, the Cm\RedisSession\
autoload namespace is already taken by the colinmollenhour/php-redis-session-abstract
package.
from cm_redissession.
An important distinction between Cm_Cache_Backend_Redis
and Cm_RedisSession
is that the former is just a class that extends Zend_Cache_Backend_Abstract
and can be used anywhere and the latter is a Magento module which is designed to have classes loaded via Varien_Autoload
. Does your custom Magento setup not use Varien_Autoload
?
from cm_redissession.
Your last example looks fine for your project composer.json file but for a module I don't think it is a proper use of composer so I'd prefer not to commit it to this repo.
from cm_redissession.
Related Issues (20)
- Connectivity issue with Azure Redis Cache HOT 1
- Configuration changes don't take effect HOT 3
- hard coded session expiry HOT 5
- Magento 1.7.0.2 and PHP 7.x HOT 1
- Fatal Error when compilation is enabled HOT 4
- Passing glue string after array is deprecated. Swap the parameters in colinmollenhour/credis/Client.php on line 1414 HOT 4
- Cm\RedisSession\Handler::read taking more than 6sec HOT 14
- Session storage - Too many active connections HOT 2
- Tag current version master HOT 1
- Magento 2 switching to Laminas instead of Zend (ZF2) HOT 3
- Experiencing delay problems HOT 1
- PHP Warning: Module 'redis' already loaded in Unknown on line 0 HOT 1
- Make setSaveHandler() only callable once
- Separate read-only instance from read/write instance HOT 5
- missing ConfigInterface HOT 1
- Session IDs are plain text in redis (missing hash) HOT 1
- Native Magento Redis Session extension HOT 1
- How can I install a specific version of this module via modman? HOT 4
- Error cleaning cache by mode matchingAnyTag: A pipeline is already in use and only one pipeline is supported. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cm_redissession.