Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Warning: require_once(__DIR__/mvc.php)

[WORKAROUND]Warning: require_once(__DIR__/mvc.php) 12 Jul 2013 14:55 #7940

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi Admin,
Have this error on two components downloaded tonight

Warning: require_once(__DIR__/mvc.php) [function.require-once]: failed to open stream: No such file or directory in ..../..../administrator/components/com_componentname/helpers/loader.php on line 133

Fatal error: require_once() [function.require]: Failed opening required '__DIR__/mvc.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in
..../...../administrator/components/com_componentname/helpers/loader.php on line 133

/administrator/helpers/loader.php
// Handle cross compatibilities
require_once(__DIR__ .DS. 'mvc.php');

// Load the component Dependencies
require_once(__DIR__ .DS. 'helper.php');

administrator/dom/dom.php
/*
	 * Constuctor
	 *
	 * 	@namespace 	: requested class
	 *  @options	: Configuration
	 *
	 */
	public function __construct($args = null)
	{
		$this->arg('namespace'	, 0, $args);
		$this->arg('options'	, 1, $args);

		$this->args = $args;
		
		CkJLoader::registerPrefix('JDom', __DIR__);
		CkJLoader::discover('JDom', __DIR__);

		$this->app = JFactory::getApplication();
		
		$this->registerFrameworks();


// AND Further Down

	protected function assetsDir()
	{
		if (!$this->assetName)
			return;
		
		return __DIR__ .DS. 'assets' .DS. $this->assetName;
	}
	}
Last Edit: 12 Jul 2013 18:28 by BTB300.
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 12 Jul 2013 16:23 #7944

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hey Admin I think i solved your random issue noted in the loader.php

// Register all Models because of unsolved random JLoader issue.
// Cook offers 3 months subscribtion for the person who solve this issue.

Perhaps your constants defined in the file.php get markers function the component site and component admin constants are incorrect

JPATH_ADMIN_COMPONENTNAME is one directory lower
Although I thought I did read somwhere that they could be defined as above (unsure)

// The correct directory constants - as defined at http://docs.joomla.org/Constants
'COM_ADMIN' => JPATH_COMPONENT_ADMINISTRATOR
COM_SITE' => JPATH_COMPONENT_SITE

// The correct directory example
CkJLoader::discover('ComponentnameClass', JPATH_COMPONENT_ADMINISTRATOR .DS.'classes');

/administrator/components/com_mycomname/classes/file/file.php
The current
public static function getMarkers()
{
     .......................
     ................
    .................
      'COM_ADMIN' => JPATH_ADMIN_COMPONENTNAME,
       'ADMIN' => JPATH_ADMINISTRATOR,
	'COM_SITE' => JPATH_SITE_COMPONENTNAME,
	'IMAGES' => JPATH_SITE .DS. $config->get('image_path', 'images')  .DS,
	'MEDIAS' => JPATH_SITE .DS. $configMedias->get('file_path', 'images') .DS,
	'ROOT' => JPATH_SITE
	);
}

the correct definitions are listed below
public static function getMarkers()
{
   .......................
   ................
   .................
	'COM_ADMIN' => JPATH_COMPONENT_ADMINISTRATOR, // <=== HERE AS IS (NOT THE COMPONENT NAME)
	'ADMIN' => JPATH_ADMINISTRATOR,
	'COM_SITE' => JPATH_COMPONENT_SITE, // <=== HERE AS IS (NOT THE COMPONENT NAME) 
	'IMAGES' => JPATH_SITE .DS. $config->get('image_path', 'images')  .DS,
	'MEDIAS' => JPATH_SITE .DS. $configMedias->get('file_path', 'images') .DS,
	'ROOT' => JPATH_SITE
	);
}
// And i believe that the solution is replace __DIR__ with
JPATH_COMPONENT_ADMINISTRATOR .DS.'heplers'

// Handle cross compatibilities
require_once(JPATH_COMPONENT_ADMINISTRATOR .DS.'heplers' .DS. 'mvc.php');

// Load the component Dependencies
require_once(JPATH_COMPONENT_ADMINISTRATOR .DS.'helpers' .DS. 'helper.php');

I Could be wrong ??
Last Edit: 12 Jul 2013 18:28 by BTB300.
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 12 Jul 2013 17:19 #7945

Hallo,

i have the same problem. I hope it will be solved as soon as possible.
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 12 Jul 2013 17:48 #7946

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
OK - for those having the same issue i have made the following changes and the component appears to be functioning correctly

Look in the get markers function for 'COM_ADMIN' => JPATH_ADMIN_[YOUR COMPONENTNAME OR PART THERE OF]
/administrator/components/com_mycomname/classes/file/file.php
public static function getMarkers()
{
     .......................
     ................
    .................
      'COM_ADMIN' => JPATH_ADMIN_COMPONENTNAME, // <== HERE FOR ADMIN
       'ADMIN' => JPATH_ADMINISTRATOR,
	'COM_SITE' => JPATH_SITE_COMPONENTNAME, // <== HERE FOR SITE 
	'IMAGES' => JPATH_SITE .DS. $config->get('image_path', 'images')  .DS,
	'MEDIAS' => JPATH_SITE .DS. $configMedias->get('file_path', 'images') .DS,
	'ROOT' => JPATH_SITE
	);
}

Done a component wide search and replace on the following

Search: JPATH_ADMIN_MYCOMPONENTNAME
Replace with: JPATH_COMPONENT_ADMINISTRATOR // <== AS IS NOT THE COMPONENT NAME!!!

Search: JPATH_SITE_MYCOMPONENTNAME
Replace with: JPATH_COMPONENT_SITE // <== AS IS NOT THE COMPONENT NAME!!!

and made the following changes to replace the __DIR__ in 5 places
(note there is slight differences in each area - so please do not paste the same line in 5 places)

administrator/components/com_mycomponent/dom/dom.php
public function __construct($args = null)
{
	$this->arg('namespace'	, 0, $args);
	$this->arg('options'	, 1, $args);

	$this->args = $args;
		
         // WAS CkJLoader::registerPrefix('JDom', __DIR__ );
	CkJLoader::registerPrefix('JDom', JPATH_COMPONENT_ADMINISTRATOR .DS.'dom' .DS ); //<== HERE
                
        // WAS CkJLoader::discover('JDom', __DIR__ );
	CkJLoader::discover('JDom', JPATH_COMPONENT_ADMINISTRATOR .DS.'dom' .DS ); //<== HERE

	$this->app = JFactory::getApplication();
		
	$this->registerFrameworks();
}
AND a little further down dom.php
administrator/components/com_mycomponent/dom/dom.php
protected function assetsDir()
{
	if (!$this->assetName)
		return;
	
        // WAS return __DIR__ .DS. 'assets' .DS. $this->assetName; 
	return JPATH_COMPONENT_ADMINISTRATOR .DS. 'assets' .DS. $this->assetName;  // <== HERE
}

administrator/components/com_mycomponent/helpers/loader.php
// Handle cross compatibilities
// WAS require_once(__DIR__ .DS. 'helpers' .DS. 'mvc.php');
require_once(JPATH_COMPONENT_ADMINISTRATOR .DS. 'helpers' .DS. 'mvc.php'); //<== HERE
administrator/components/com_mycomponent/helpers/loader.php
// Load the component Dependencies
// WAS require_once(__DIR__ .DS. 'helpers'  .DS. 'helper.php');
require_once(JPATH_COMPONENT_ADMINISTRATOR .DS. 'helpers'  .DS. 'helper.php'); //<== HERE

Hope it saves someone a headache ;)
Last Edit: 12 Jul 2013 18:12 by BTB300.
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 12 Jul 2013 20:24 #7947

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi There everyone!!
Just To Confirm That I have now done the above on two more of my components downloaded tonight and it works!
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 13 Jul 2013 12:22 #7950

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Yes, I see, but when you load your component loader from a module, is it working ?

When your page is another component, JPATH_COMPONENT_ADMINISTRATOR is corrupted.
This is the reason why I am using those constants.
JPATH_ADMIN_COMPONENTNAME is one directory lower
Although I thought I did read somwhere that they could be defined as above (unsure)
What do you mean ?
Coding is now a piece of cake
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 13 Jul 2013 12:26 #7951

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Failed opening required '__DIR__/mvc.php'

__DIR__ is not interpretated by your PHP because string above output '__DIR__' litterrally.
Coding is now a piece of cake
The administrator has disabled public write access.

Warning: require_once(__DIR__/mvc.php) 16 Jul 2013 04:24 #10474

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
admin wrote:
JPATH_ADMIN_COMPONENTNAME is one directory lower
Although I thought I did read somwhere that they could be defined as above (unsure)
What do you mean ?
Um not really sure what i was trying to say... a late night 1/2 asleep i guess??
The administrator has disabled public write access.

[SOLVED] Warning: require_once(__DIR__/mvc.php) 16 Jul 2013 04:41 #10475

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
admin wrote:
Failed opening required '__DIR__/mvc.php'

__DIR__ is not interpretated by your PHP because string above output '__DIR__' litterrally.

Yes thanks Admin
Found the source of the issue hosted server running php 5.2...
simply replacing the __DIR__ constant with dirname(__FILE__) Solved the issue on php 5.2

Found Admins Solution even easier www.j-cook.net/index.php/forum/trouble-s...fined-constant#10471
Last Edit: 16 Jul 2013 04:46 by BTB300.
The administrator has disabled public write access.

[SOLVED] Warning: require_once(__DIR__/mvc.php) 20 Jul 2013 23:08 #10538

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Fixed
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.084 seconds

Get Started