0

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.

  • Welcome to JSE. You will probably need to change 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__).'/..' )); – Lodder Apr 16 at 12:03
0

Since your JPATH_BASE is not $_SERVER[ 'DOCUMENT_ROOT' ] anymore thus the required files fail to open.

You can try few things:

  1. Comment out the line which wrongly defines JPATH_BASE on the top of your files. This can handle the error. Since JPATH_BASE is already defined globally.

  2. Or Define JPATH_BASE correctly on the top of your files, like: define( 'JPATH_BASE', $_SERVER[ 'DOCUMENT_ROOT'] . ‘/elib’ ); - this can also handle the issue.

  3. Or better path definition as @Lodder gave in his comment: define( 'JPATH_BASE', realpath(dirname(__FILE__).'/..' ));

  4. In above PHP 7.0 : define( ‘JPATH_BASE’, dirname(__DIR__, 1));

But again, JPATH_BASE does not have to be defined on the top of the files, since JPATH_BASE is defined in _path_/index.php. (reference)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.