Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
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;
	}
	}

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
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 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 ??

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

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.

Please Log in or Create an account to join the conversation.

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
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 ;)

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132
Hi There everyone!!
Just To Confirm That I have now done the above on two more of my components downloaded tonight and it works!

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
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

Please Log in or Create an account to join the conversation.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986

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

Please Log in or Create an account to join the conversation.

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132

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??

Please Log in or Create an account to join the conversation.

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

  • BTB300
  • BTB300's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
  • Posts: 415
  • Thank you received: 132

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

Please Log in or Create an account to join the conversation.

Last edit: by BTB300.

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.177 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started