TYPO3 / CmsComposerInstallers

TYPO3 CMS Composer Installer
GNU General Public License v2.0
58 stars 39 forks source link

__DIR__ differences on Windows / Mac at autoload.php #30

Closed aregnet closed 9 years ago

aregnet commented 9 years ago

Hi, I have a problem with the latest version of TYPO3 / Composer on Windows (xampp).

Warning: require_once(C:\xampp\htdocs\typo37\vendor\typo3\cms\vendor/composer/autoload_real.php): failed to open stream: No such file or directory in C:\xampp\htdocs\typo37\vendor\typo3\cms\vendor\autoload.php on line 5

/vendor/typo3/cms/vendor/autoload.php is a symlink to vendor/autoload.php

With Mac OSX there is no such error. I figured out that the "DIR" constant is different on Windows and Unix.

In my example with the autoload.php file: Mac: Path to the resolved file (vendor/) Windows: Path to the symlinked file (vendor/typo3/cms/vendor/)

With this differences the require_once in autoload.php (Line 5) failes on Windows.

Is there any solution for this? Thanks.

helhum commented 9 years ago

To me the error message looks like C:\xampp\htdocs\typo37\vendor\typo3\cms\vendor\autoload.php isn't a link but a file.

Can you please show me the directory listing of C:\xampp\htdocs\typo37\vendor\typo3\cms\vendor\ and C:\xampp\htdocs\typo37\vendor\

helhum commented 9 years ago

I have a problem with the latest version of TYPO3 / Composer on Windows

what exact TYPO3 version and what exact installer version do you have?

aregnet commented 9 years ago

I'm using the dev-master of TYPO3 CMS. The composer.json of my typo3/cms package requires:

...
"typo3/class-alias-loader": "^1.0",
"typo3/cms-composer-installers": "^1.2.2"

Directory listing: autoload

helhum commented 9 years ago

Thanks. And you get the error message for a frontend request? Does CLI or backend request work for you?

aregnet commented 9 years ago

Yes, the error occurs just on frontend requests. BE works fine.

helhum commented 9 years ago

Ok, can you show me a directory listing of your web directory? Is the index.php file also symlinked?

helhum commented 9 years ago

and is the typo3 folder symlinked?

aregnet commented 9 years ago

Thanks for your hint. We're using a post-update / post-install command to remove the symlink and copy the index.php file instead, because our hoster (domainfactory) doesn't allow the index.php to be a symlink.

The weird thing is that this workaround is working on Mac and Live Server (also Unix) but not on Windows.

Do you know any solution that help us to handle this three systems but use the same sources? Thanks.

aregnet commented 9 years ago

When the index.php is a symlink, then there is no error in the frontend

helhum commented 9 years ago

If the index.php file is a symlink the error in FE is gone

Well. The question now is: Why wasn't this file a symlink? If you do a clean composer install with admin permissions (required to set symlinks on Windows), is the index.php a symlink or a file? Is the typo3 directory a symlink or a file in that case?

aregnet commented 9 years ago

Both the typo3 directory and the index.php files are symlinks if I do a clean composer install.

We're using composer scripts (https://github.com/TYPO3/CmsComposerInstallers/issues/21) to workaround the problem we have with the hoster.

It would be nice if we could use the same composer.json for all our systems, but the method above don't work with the current dev-master.

helhum commented 9 years ago

Both the typo3 directory and the index.php files are symlinks if I do a clean composer install.

So this issue is resolved for you?

helhum commented 9 years ago

We're using composer scripts (#21) to workaround the problem we have with the hoster.

Your hoster is on Windows?

aregnet commented 9 years ago

So this issue is resolved for you?

Yes and no. I know that the problem is the copied index.php file, but we need this for our hoster.

Local Development System: Windows (needs to have a symlinked index.php file) Hoster: Unix (can't use symlinked index.php)

Is there a solution that uses the same composer.json file and fit both needs?

helhum commented 9 years ago

It would be nice if we could use the same composer.json for all our systems, but the method above don't work with the current dev-master.

Ah, ok, I maybe got your point. You have this composer.json to avoid issues with your hoster and want to use the same composer.json for your Windows dev-system?

This imho is a deployment issue.

Anyway, if you change the script path to not copy the original index.php file but one that changes the line:

$classLoader = require __DIR__ . '/typo3/../vendor/autoload.php'; to $classLoader = require realpath(__DIR__ . '/typo3') . '/../vendor/autoload.php'; then this index.php will also work on Windows.

We're working on a refactoring of this part of the installer. It will in the end be possible to decide whether something should be linked, copied to the web directory or not at all.

For the time being you have to live with this small workaround

helhum commented 9 years ago

I'll close this ticket now in favor of #21 which will be resolved with the refactoring mentioned above

helhum commented 9 years ago

Is there a solution that uses the same composer.json file and fit both needs?

Leave out the manipulation of the index.php in your composer,json and let your deployment script do the job that is required for your hoster