'Zend_Session_Exception Error in Zend Framework - php

I have a website in zend framework which is install in another server. Now I have purchase a new server in ubuntu with Zend Engine 2.3.0 . I have installed Apache server, MYSQL , PHPMYADMIN Tool on this server. Then I upload all the files on previous server to the new server. I have also change the urls in the index.php files.
But it is giving me error.
**Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /var/www/sample/library/Zend/Session.php(Line:477):Error #2 session_start(): open(/vlk_session/sess_ielitiholu4219p3nph6lkk8n6, O_RDWR) failed: No such file or directory (2) /var/www/videoliked/library/Zend/Session.php(Line:487): **
This is my below code of index.php file
Zend_Layout::startMvc($options);
Zend_Session::setOptions(array('save_path'=>'/vlk_session'));
if(isset($_COOKIE["Zend_Auth_RememberMe"]) && $_COOKIE["Zend_Auth_RememberMe"] !== false){
Zend_Session::rememberMe("5302000");
setcookie("Zend_Auth_RememberMe", false, time(), "/");
}
if(!Zend_Session::isStarted()){
Zend_Session::start();
}

The save path is absolute.
Did you create the folder /vlk_session on your server?
I'd suggest to use and create
/tmp/vlk_session
Instead, or lookup the PHP default folder for sessions in your php.ini and use the one suggested by vendor.
Update:
Make sure the PHP instance is allowed to read/write that folder.

Related

php - Unknown: Failed opening required on line 0. laravel 5.6

I just installed laracast/flash and updated nesbot/carbon via composer. The cmd went nuts while downloading carbon. Cmd interface displayed scattered words and boxes all over the interface for a while and the download was completed.
Did php artisan serve at localhost:8000 and I've got the following errors.
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'C:\xampp\htdocs\NC World\ProjectName\server.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0
This error happens because the server.php file is missing. May be it is deleted or removed from your project directory. I have already faced this problem. Just add the server.php file at root of your project. You can add this file from any other laravel project directory or just create a file named server.php at root directory of your laravel project and paste the following code:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
This process works for me.
Try to disable your anti-virus, this happens to me, it seems avast deletes my server.php.
So I added it to the exception
Type in the command line:
php -S localhost:8000 -t public
because port is not public
go to main directory and create new server.php file even you can also copy paste from another created project
same happens to me and i just remove antivirus from my system and just create new file of server
You can also go in your antivurus params and restore server.php + add an exception it worked fine for me without recreate a project.
same problem happen to me:
just delete the project and uninstall the avast antivirus and re create the project
This same thing happens with me just create new laravel project and copy server.php from the new project and paste it to your project

Error in setting laravel project in another PC locally

I am new in laravel. My friend gives me a project to study, but when I set that project on my localhost I receive some error. Can Anyone help me to set that project on my PC.
I Uploaded the server file code[enter image description here][1]
**
Error: Warning: require_once(C:\wamp64\www\hazir/public/index.php): failed to open stream: No such file or directory in C:\wamp64\www\hazir\server.php on line 21 Fatal error: require_once(): Failed opening required 'C:\wamp64\www\hazir/public/index.php' (include_path='.;C:\php\pear') in C:\wamp64\www\hazir\server.php on line 21
**
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
It seems that you alter the Laravel app and created a file server.php. and accessing files via URI on the public directory of Laravel. Unfortunately, that's not how Laravel application works.
I assumed you're using a Wampserver, by using this, it may cause you a bit of trouble in setting up Laravel app on your machine. I highly suggest using Laragon or the Laravel created Homestead

Joomla add article via php script Application Instantiation Error

i created a script in order to insert some articles via a php script. This script is working on my local machine (xampp), but when i deploy the whole joomla project to my web server i get the following error message:
Error displaying the error page: Application Instantiation Error: Application Instantiation Error
By adding some echo calls, i was able to find the line which causes the error:
$app = JFactory::getApplication('site');
Now i am wondering how to fix this behaviour and make my function also run on the web server.
Below i will provide my system informations and the beginning of my php function until the line, which causes the error message:
Systeminformations
joomla version: 3.6.5 Stable
db version: 5.6.34-79.1-log
php version: 5.6.30-he.0
web server: Apache
PHP snippet
<?php
echo "STARTING; ";
// get db connection
include('../includes/mysql.inc.php');
// get all sql querys
include('./autoNewsQuerys.inc.php');
/**
* Prepare joomla framework to insert article correctly
*/
if (!defined('_JEXEC')) {
define('_JEXEC', 1);
define('JPATH_BASE','/is/htdocs/wp1088688_4E1H7PYJFK/www');
require_once(JPATH_BASE . '/includes/defines.php');
require_once(JPATH_BASE . '/includes/framework.php');
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
}
echo "searching app;";
$app = JFactory::getApplication('site');
echo "Found app;";
Full browser output
STARTING; searching app;Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/is/htdocs/wp1088688_4E1H7PYJFK/www/1500AutoNews/autoNews.php" at line 3.
So as you can see the error is caused by the JFactory call. 'Found app' is never printed out.
Just copy the Joomla index.php file to another file and then replace the $app->execute code with your code.
Note: You don't need to include any MySQL library - since you are loading the Joomla environment then you have access to the JDatabase class, which is a database abstraction layer.
Another note: this file autoNewsQuerys.inc.php likely contains some issues (maybe you are trying to instantiate the app there, but the Joomla environment hasn't loaded yet). You should move it to the end.
if it was working on localhost and it is not working on Web server then the biggest issue is with defining the base path. Give a hardcoded base path of your joomla installation. I suggest you to check your base path using a php script. Create a php file and name it path.php. Put it in the Joomla main folder. Content of the file
<?php
echo "The Base path is ".getcwd();
?>
Once you get the path just change the Base_Path. For ex:
define('JPATH_BASE', '\var\www\joomla');

unable to create PHAR archive

im a PHP newbie . .
i've tried to make a PHAR of my project.
my project include 5 directories and multiply classes within each dir.
I've followed this tutorial
Phar – PHP archiving practice
and i did the following:
to my main index.php i added this lines:
$sLibraryPath = 'lib/myPhar.phar';
// we will build library in case if it not exist
if (! file_exists($sLibraryPath)) {
ini_set("phar.readonly", 0); // Could be done in php.ini
$oPhar = new Phar($sLibraryPath); // creating new Phar
$oPhar->setDefaultStub('index.php', 'classes/index.php'); // pointing main file which require all classes
$oPhar->buildFromDirectory('classes/'); // creating our library using whole directory
$oPhar->compress(Phar::GZ); // plus - compressing it into gzip
}
and i created a new folder called classes , and created a index.php file within it, and there i included all my project classes.
i've chmod 777 the following directories: lib, HelloWorld , HelloWorld/index.php ,
and changed the phar.readonly. (phar.readonly = 0)
still i get this message:
Fatal error: Uncaught exception 'PharException' with message 'unable to create temporary file' in /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php:10 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php(10): Phar->setDefaultStub('index.php', 'classes/index.p...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/HelloWorld/index.php on line 10
i havent found any helpful info what to do with it, and i will glad for your help.
(if there is a better way to create PHAR it will be fine)
I'm not sure if it is the point, but check this link Bug #63112 PharException when compiling
May be you have the same trouble with temp directory?
Use the PHP2Phar package to create your Phar file from PHP files.
Link:
https://github.com/00F100/php2phar
Usage:
$ php php2phar.phar --dir-source <path/to/dir> --index-file </path/to/index.php> --output-file <path/to/file.phar>

Smarty template not working on local server

I am having trouble getting the Smarty Template Engine to work correctly on my local test server. I have it set up like this:
<?php
// put full path to Smarty.class.php
require('smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->testInstall();
$smarty->setTemplateDir('smarty/templates');
$smarty->setCompileDir('smarty/templates_c');
$smarty->setCacheDir('smarty/cache');
$smarty->setConfigDir('smarty/configs');
$smarty->assign('name', 'Ned');
$smarty->display('index.tpl');
?>
However, I keep getting this error:
Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'index.tpl'' in /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace: #0 /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php(374): Smarty_Internal_TemplateBase->fetch('index.tpl', NULL, NULL, NULL, true) #1 /var/www/WEBSITE/test.php(13): Smarty_Internal_TemplateBase->display('index.tpl') #2 {main} thrown in /var/www/WEBSITE/smarty/sysplugins/smarty_internal_templatebase.php on line 127
I used the testInstall function and this was returned:
Smarty Installation test...
Testing template directory...
/var/www/SteamKing/templates is OK.
Testing compile directory...
FAILED: /var/www/SteamKing/templates_c is not writable.
Testing plugins directory...
/var/www/SteamKing/smarty/plugins is OK.
Testing cache directory...
FAILED: /var/www/SteamKing/cache is not writable.
Testing configs directory...
FAILED: ./configs/ does not exist.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.
I went through the whole making sure the folders are actually writable and everything but I still get the error. Any ideas?
Well for one thing the paths to your templates are wrong where you're assigning paths. The path is /var/www/SteamKing not smarty/
It's usually a good idea to use absolute paths so you can move your files around without worrying about where your templates go.
As for why your cache and template_c is not writable you need to show the actual paths or show the command you used to try to make them writable.

Categories