Zend Framework 2 is not letting me use orginal PHP session. I am using Responsive File Manager Application that is in public folder of zend framework 2. Whenever the dialog of file manager opens, I get following error.
Warning: Class __PHP_Incomplete_Class has no unserializer in E:\xampp\htdocs\MantissaAdmin\public\ResponsiveFilemanager\filemanager\config\config.php on line 2
Where on line 2, the code is
session_start();
How can I make it so that Zend framework 2 do not interfere with the file manager session.
This is not an issue of ZF2. There is a serialized object in your session which php tries to unserialize when session_start is called. But because PHP can't find the class (which is not declared), it uses __PHP_Incomplete_Class instead.
See: PHP: unserialize - Manual
The best way to fix: Register an autoloader to load missing classes. You can dump the class name this way:
ini_set('unserialize_callback_func', '__unserialize_callback_func');
function __unserialize_callback_func($classname)
{
var_dump($classname);
}
session_start();
In order to work with other 3rd party libraries and share sessions across software that may not be ZF2 related; you will need to ensure that you still provide access to the ZF2 autoloader as well as module autoloading. In the shared software make certain before the session starts that you bootstrap the ZF2 autoloader and initialize the ZF2 Application.
$cwd = getcwd();
chdir('/path/to/zf2-application');
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
chdir($cwd);
session_start();
Related
I am using Codeigniter 3.0.1 in a Wamp64 installation (PHP Ver 5.6.19, Apache 2.4.18) on a Windows Server 2012 R2.
When I have the line:
$autoload['libraries'] = array('session');
in autoload.php I get the following error on startup of my application:
ini_set() A session is active You cannot change the session module's
ini settings at this time. Filename: libraries/Session.php Line
Number: 313
If I take that line out of autoload.php and put the following line in the contructor function of the controllers that actually use the session data:
$this->load->library("Session")
I get the same error, but only when I start one of those controllers.
I have reviewed multiple answers to this question on stackoverflow:
Do you have a session_start() in your php code: NO - I have searched every piece of code included in this project and there is no session_start() anywhere
Do you have session.auto_start set equal to 0 (zero) in php.ini - YES
Neither of these answers solves my problem.
Session info is being written out to C:\temp on the server. I see the file is created when I start the controller that first loads the Session library so the web server seems to have write access to the C:\temp folder.
The other interesting thing is that I have no problem with the installation on my test server (Windows 7, php version 5.6.32)
Can anyone offer any suggestions? Thanks!
One more piece of information: This was an upgrade from 2.x to 3.0. I did delete the \system sub folder and replaced it with the V3 \system folder.
Found it.
The issue was an Ajax library (Sijax) which external to Codeigniter instantiated an instance of the class so that the methods could be called via Ajax. The new(class) triggered loading the Session class again, which ran through the initialization and tried to create the session again.
I removed the autoload of the Session class, and moved loading it to the Classes that require it, checking first to see if the Class already exists before calling the loader.
I'm new in CI and now I'm trying to use CodeIgniter 3 to develop my site. I just only extract the framework and change only one think in config/autoload.php file:
$autoload['libraries'] = array('database','input');
when I run the site, an error occur:
Unable to load the requested class: Input
When I tried it with CI version 2.2.0 stable, every thing is OK, no errors
Could some one explain why and help me to solve it?
As of documentation input library is loaded by default.
This class (input) is initialized automatically by the system so there is no need to do it manually.
Autoloading documentation http://www.codeigniter.com/userguide3/general/autoloader.html
By default the library load from system/core folder in you CI. But the Input library is located on the core folder so you need to give relative path to the Input.php like this
$autoload['libraries'] = array('database','../core/input');
I am php developer use laravel-4 as framework for building web applications , in the last few days I wanted to create phar file from my web application created on laravel framework .
I searched in the web for tools build php archive files (.phar) and I found
PHP box , this tool is very good and use json configuration file for building the phar files but i could not use it for creating my phar files because there is many considerations when creating phar file from a web application use a framework like laravel . my questions are :
laravel use composer autoloader as auto loading mechanism
1- how to handle composer auto loading mechanism ?
2- how to handle the framework bootstrapping process ? 'like laravel'
3- what i need to make the browser read my index page from inside the phar file ?
4- how to use framework command line tools from the phar file ? 'like laravel-artisan'
You might use composer.json in your application and require box there.
When your application runs on laravel, you know that your bootstrap works and would also work inside a phar.
I believe Box brings a lot of the composer autloading stuff itself, so you won't run into trouble with it. I think the class_map gets included automatically.
One thing to consider is, that configuration details must be passed in!
In general, you need to "forward" to your application, which is inside the phar, like so:
<?php
require_once "phar://myapp.phar/frontcontroller.php"; // maybe index.php
$config = array('dsn' => 'database-config');
Application::run($config);
Also accessing a PHAR in a PHAR is a problem!
You can't access a PHAR packaged in a PHAR directly.
Firstly you need to extract the packaged PHAR, secondly do the forwarding call and pass the CLI commands along. Problem solved here: https://stackoverflow.com/a/13537329/1163786
Full Example
box.json.dist
{
"main": "bootstrap.php",
"output": "application.phar",
"compactors": ["Herrera\\Box\\Compactor\\Composer"],
"chmod": "0755",
"directories": ["src/"],
"stub": true
}
bootstrap.php
<?php
require 'vendor/autoload.php'; //<-- this is autoload.php generated by Composer
use MyApp\Application;
$config = parse_ini_file(__DIR__.'/config.ini');
$app = new Application();
$app->run($config);
When trying to implement this framework I ran into a issue with the directory. When I attemt to use this Zend i end up with
Interface 'Zend\Mail\Storage\Folder\FolderInterface' not found in /home/content/54/9595754/html/zend/library/Zend/Mail/Storage/Imap.php
In the index.php file where I try to display the emails. I use an:
set_include_path
include require_once('Imap.php');
The contents of Imap.php looks like:
namespace Zend\Mail\Storage;
use Zend\Mail;
use Zend\Mail\Protocol;
class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\WritableInterface
So what would i need to add to the Imap.php so that it dosent look inside this directory for the file.
I know understand that I need to try to implement a file in order for the framework to understand the directory they are in however when i try to implement an autoloader I get an error see example below.
require_once '../../../library/Zend/Loader/Autoloader.php';
Yields
require_once(Zend/Loader.php) [function.require-once]: failed to open stream:
No such file or directory in /home/content/54/9595754/html/zend/library/Zend/
Loader/Autoloader.php
Zend framework 2 and most other modern frameworks rely on autoloading for class loading.
You have only required the Imap class but not the dependent interfaces. That's why you get this fatal error.
I'd suggest you setup autoloading in your application. For an example how to set this up you can have a look into init_autoloader.php from the ZendSkeletonApplication.
I am wanting to use the Symfony\Component\Process\ProcessBuilder class and can see that it is included as part of the Silex codebase within the vendors folder. I am using the Silex phar file and assume that because I can readily instantiate other Symfony components like Request, Response and so on that it will correctly locate the file to include when I use the full namespace.
$foo = new Symfony\Component\HttpFoundation\Request(); //works fine
However, when I try and create and instance of it using:
$foo = new Symfony\Component\Process\ProcessBuilder(); //class not found
It gives me a class not found error. Does anyone know why this is and how I can use this class from the Silex phar without including the component seperately within my project?
It looks like the Process Symfony component is not included in the compiled Silex phar file.