Error in setting laravel project in another PC locally - php

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

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

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');

API logging using log4php

I have log4php working via the command line successfully but I am struggling when using it with an PHP API (via Apache).
The error I am getting is;
PHP Warning: log4php: Configuration failed. Error loading configuration file: failed
to load external entity "logging.xml"
logging.xml is in the same directory as the PHP file and is loaded via;
$configFile = "logging.xml";
Logger::configure($configFile);
Ideas please? I tried changing it to use the full URL for the file and the full local path and they result in the same error.
The same setup works via the CLI.

'Zend_Session_Exception Error in Zend Framework

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.

CakePHP 2.1 bake test app and failed

I download cakephp 2.1 from the official website. When I copied files to my www directory on Windows 7 64bit, (using WAMP 2.2 with PHP 5.3.8), and configured path to link to cake bake.bat in console folder I have problem. When I run cmd and typing cake bake testapp (to generate some test app and test new futures) I see in console strength error:
File app/View\Pages\home.ctp exists
Do you want to overwrite?
I answered y. The bake app is ready but If I type my localhost in my browser I see
The action index is not defined in controller AppController
so I type manual pages to url I see 404!
Please help me because I want start a new project with new CakePHP 2.1 not 2.0.6...
This issue is fixed.
If you still getting error comment the following code in C:\wamp\www\cake\lib\Cake\Console\Command\Task\ProjectTask.php file
if ($this->createHome($path)) {
$this->out(__d('cake_console', ' * Welcome page created'));
} else {
$this->err(__d('cake_console', 'The Welcome page was <error>NOT</error> created'));
$success = false;
}
NOTE: C:\wamp\www\cake - This is my cake liberary path, change yours if its different.

Categories