box-project/box

Does the box support laravel? If so, can a box.json be provided?

zh7314 opened this issue · 3 comments

Does the box support laravel? If so, can a box.json be provided? I have tried many times but have failed

I thought there was a doc entry for it, but looks like there is only a Symfony one.

To answer your question though, yes Laravel is supported. There should not be any framework that inherently cannot be supported. There is a few caveats of course, but it has more to do with PHARs than Box:

  • a PHAR is a readonly environment, that means if you have any write operation like a cache warmup, it needs to be done before shipping the code into the PHAR.
  • as per above, if you do write temporary files, you need to adjust your application to write somewhere on the disk and not in the PHAR.
  • it won't work for a webserver (PHARs do fine with it, but it's an old way with a very big and complicated API, I just removed all support for it when worked on Box because it was something I was not familiar with and not worth doing).

I think most of of what is written in the Symfony doc goes for Laravel, and as a matter of fact there is LaravelZero which is a more tailored distribution of Laravel for CLI applications and it uses Box for its compilation.

Thank you. I tried the documentation about Symfony, but it still failed. I will try LaravelZero

It is possible with Laravel, currently working on a project at work that uses Laravel within a PHAR for over 2 years now. There are some quirks and workarounds required! The most important one to overcome is realpath.

I 'patch' certain Laravel dependencies via a custom Application and inject/override specific files, try to leave as much as possible intact. So whenever we need to update libraries I hardly have to update patches what-so-ever.