I built a small website using Joomla 3.4.0./ Wampserver 2.4 on Windows 8.1 Pro.
Now I've upgraded the computer to Windows 10 Pro and Wamp 3.1.7 (64 bit). I've rebuilt the website with latest version of Joomla 3.9.3 from scratch, and it's working fine EXCEPT all those custom modules which access the user object. I haven't changed anything yet. I'm getting errors as below:
( ! ) Warning: require_once(C:/wamp64/www\includes\defines.php): failed to open stream: No such file or directory in C:\wamp64\www\clib\custom\CreateNewAcc.php on line 9
Call Stack
# Time Memory Function Location
1 0.0162 404168 {main}( ) ...\CreateNewAcc.php:0( ! ) Fatal error: require_once(): Failed opening required 'C:/wamp64/www\includes\defines.php' (include_path='.;C:\php\pear') in C:\wamp64\www\clib\custom\CreateNewAcc.php on line 9
Call Stack
# Time Memory Function Location
1 0.0162 404168 {main}( ) ...\CreateNewAcc.php:0
Each of my custom code files such as 'CreateNewAcc.php' begin like this:
<?php
/**/
#uncomment in joomla
$mf1="";
define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ] );
require_once( JPATH_BASE . DS . 'includes' . DS . 'defines.php' );
require_once( JPATH_BASE . DS . 'includes' . DS . 'framework.php' );
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'factory.php' );
$mf1 = JFactory::getApplication('site');
date_default_timezone_set("Asia/Calcutta");
$user = JFactory::getUser();
$uname=$user->name;
$uid=$user->id;
$date= JFactory::getDate();
?>
What I have tried:
I've checked the location of defines.php & CreateNewAcc.php files -- they're okay.
Earlier site was in the root of www folder, now it's in a folder of its own named 'elib' (virtual host) within www.
define('JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT' ]);
to something that points to the root of your Joomla installation. Try something like:define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' ));