Project

General

Profile

Actions

Bug #69563

closed

Autoloader looks in wrong directory for class files

Added by Thomas Hucke over 8 years ago. Updated over 8 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
composer
Target version:
-
Start date:
2015-09-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I stumbeld upon this issue setting in my controller

     protected $viewFormatToObjectNameMap = array(
        'json' => 'Thucke\ThRating\View\JsonView',
    );

Normally I would expect that I have to put the file in my extension directory

EXT:th_rating/Classes/View/JsonView.php

... that doesn't work.
I figured out that TYPO3 instead looks for the following file
typo3\vendor\typo3\cms-composer-installers\Classes\Thucke\ThRating\View\JsonView.php

I'd assume that the autoloader might have a bug there.
But I'm sure you guys will find the right point to change ...

Thanks
Thomas


Files

composer.json (1.42 KB) composer.json Thomas Hucke, 2015-09-07 21:42
composer.json (1013 Bytes) composer.json Thomas Hucke, 2015-09-16 17:13
Actions #1

Updated by Stephan Großberndt over 8 years ago

  • Category changed from 1597 to composer
  • Target version deleted (7.5)
Actions #2

Updated by Wouter Wolters over 8 years ago

  • Status changed from New to Needs Feedback

How do you register your module/plugin?

Actions #3

Updated by Thomas Hucke over 8 years ago

Hi Wouter,

thanks for your quick response.
It's the normal way registering an extbase extension:

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'Thucke.' . $_EXTKEY,    // The extension name (in UpperCamelCase) or the extension key (in lower_underscore)
    'Pi1',        // A unique name of the plugin in UpperCamelCase
    array(        // An array holding the controller-action-combinations that are accessible 
        'Vote'             => 'ratinglinks,polling,mark,index,show,create,new,singleton',    // The first controller and its first action will be the default 
    ),
    array(        // An array of non-cachable controller-action-combinations (they must already be enabled)
        'Vote'             => 'new,create,ratinglinks,polling,mark',
        )
);

You may download my extension "Rating AX" from TER.
I'm trying to add JSON responses for the AJAX requests. This isn't included in the TER version yet.

Actions #4

Updated by Helmut Hummel over 8 years ago

Thomas Hucke wrote:

I stumbeld upon this issue setting in my controller

You added a new class file to your extension?

I figured out that TYPO3 instead looks for the following file

How did you find that out?

I'd assume that the autoloader might have a bug there.
But I'm sure you guys will find the right point to change ...

For now, if you do not have a composer.json with a PSR-4 section defined, you need to execute

typo3/cli_dispatch.phpsh extbase extension:dumpclassloadinginformation

after you add a class to your extension.

In future versions you will be able to set up such a PSR-4 section in your ext_emconf.php, but this is not possible yet.

Actions #5

Updated by Thomas Hucke over 8 years ago

Helmut Hummel wrote:

You added a new class file to your extension?

Yes, the new JSON view which is being referenced in the controller.

How did you find that out?

I used to check at which files the webserver is looking for when I execute the extension.
On windows there's a nice tool called "process monitor" which does a good job for that.

For now, if you do not have a composer.json with a PSR-4 section defined, you need to execute [...]
after you add a class to your extension.

Thanks - I'll try it out soon.

Actions #6

Updated by Helmut Hummel over 8 years ago

  • Status changed from Needs Feedback to Rejected
  • Assignee deleted (Anja Leichsenring)

Thomas Hucke wrote:

Yes, the new JSON view which is being referenced in the controller.

OK, then that is why the new class is not found.

How did you find that out?

I used to check at which files the webserver is looking for when I execute the extension.
On windows there's a nice tool called "process monitor" which does a good job for that.

Yeah, the class loader might look in several places when the class is not in the map

For now, if you do not have a composer.json with a PSR-4 section defined, you need to execute [...]
after you add a class to your extension.

Thanks - I'll try it out soon.

Feel free to add comments here if you have troubles with that. But I'll close the ticket now.
As said, we'll improve the situation by adding the autoload section also to ext_emconf.php
Until then you can improve the handling for yourself by adding a composer.json file with a PSR-4 section.

Here an example what is needed in such a composer.json file (and a description what section is what for) https://github.com/helhum/ext_scaffold

Actions #7

Updated by Thomas Hucke over 8 years ago

Hi Helmut,

I've created a composer.json file using the template of your ext_scaffold example.
Even it's being well documented and seems to be as easy as it can be ... MY composer.json doesn't semm to work properly.
It'd be great if you could have a look at it (see attachment) and give me a hint what's going wrong.

Thank you
Thomas

Actions #8

Updated by Thomas Hucke over 8 years ago

Hi Helmut,

this file now works.
I removed some entries of the former file which was based on the template you've referenced.

Have no clue what've been the issue in the former file.

Thank you
Thomas

Actions

Also available in: Atom PDF