Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phar symfony 6.4 #1403

Open
maitrecanard opened this issue Aug 13, 2024 · 5 comments
Open

Phar symfony 6.4 #1403

maitrecanard opened this issue Aug 13, 2024 · 5 comments

Comments

@maitrecanard
Copy link

maitrecanard commented Aug 13, 2024

Bug report

Question Answer
Box version 29c3585
PHP version 8.3.6
Platform with version linux 22
Github Repo

Hello everyone, I have an anomaly with box when I try the box compile command. Indeed when I launch the application, php returns me the following error: PHP Warning: require(phar:///var/www/html/pictav.phar/src/config/bundles.php): Failed to open stream: phar error: "src/config/bundles.php" is not a file in phar "/var/www/html/pictav.phar" .
However in the new version of symfony, the bundles.php file is located at the root of the config folder and not in src. Can you help me?

No visible error during the PHP archiving process, the error is only when launching the application, which tries to open the bundle from the src folder each time. I tried to find solutions with the Symfony doc, but I found nothing.

Thank you in advance for your help

box.json.dist
{
"main": "public/index.php",
   "output": "pictav.phar",
   "directories": [
       "bin",
       "config",
       "public",
       "src",
       "templates",
       "var",
       "vendor"
   ],
   "files": [
       ".env",
       ".env.local",
       "composer.json",
       "composer.lock",
       "symfony.lock"
   ],
   "stub": true,
   "compression": "GZ",
   "check-requirements": false
}
Output
$ command
> box compil
@theofidry
Copy link
Member

However in the new version of symfony, the bundles.php file is located at the root of the config folder and not in src. Can you help me?

But then how is calling this path?

You can check if the files you are expecting are shipped first, e.g. if the bundle.php file is there (if your IDE does not index PHARs, you can either use box info or extract it in a temporary directory).

Otherwise my guess is that the Kernel tries to guess the path but does not manage to: https://box-project.github.io/box/symfony/#project-directory

@maitrecanard
Copy link
Author

Hello and thank you for your feedback,

unfortunately I have already tried the procedure you sent me, here is the result

image

I also tried moving the folder in the Json so that the config folder would be called first. No improvement.

@theofidry
Copy link
Member

If you read the error message it shows that you are missing the : string type return that appears to be now enforced. Looks like the docs need to be updated.

I don't know the structure of your project so you need to adapt it based on that, I do not know if _DIR_.'/../' is the correct value; but your console app (not the PHAR) should still work after this change so it is easy to check (from the current error you have, I am pretty sure that doing a bin/console will just fail too).

I also tried moving the folder in the Json so that the config folder would be called first. No improvement.

I do not understand that statement, which JSON? what config folder would be called?

There is otherwise a working example within Box itself otherwise https://github.com/box-project/box/tree/main/fixtures/build/dir012.

@maitrecanard
Copy link
Author

Thank you very much for your help, it works. I just have this information on my front showing: #!/usr/bin/env php .

I'll take a closer look at what's causing this.

@theofidry
Copy link
Member

if you're rendering it as a web app, I have no clue if that works at all. There is a ton of settings for serving a web PHAR which I have no clue how it works and IMO it is a very edge case (e.g. to deploy on an FTP server), hence there is no native support within Box for it. Could be it happens to work, but could be you need to adjust a few things yourself, I honestly have no idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants