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

APP_ENV=dev is nor working - tag 5.0.4 #82

Open
pawel-holik-droptica opened this issue Jun 6, 2024 · 8 comments
Open

APP_ENV=dev is nor working - tag 5.0.4 #82

pawel-holik-droptica opened this issue Jun 6, 2024 · 8 comments

Comments

@pawel-holik-droptica
Copy link

I have tried to run Mautic (mautic/recommended-project) in Symfony dev mode with debug toolbar and without caching but it is not working.

At first, I found out that I was missing the whole require-dev section in composer.json so I copied it from mautic/mautic projects composer (same tag) - link

After installing the required packages I was struggling with IpRestrictMiddleware which restricts the APP_ENV=dev to only local IPs but it checks simply using in_array so when using docker I cannot provide the exact IP (it changes) and I cannot use mask or wildcard or anything like this with MAUTIC_CUSTOM_DEV_HOSTS env.
Fortunately, there is DDEV_TLD env that is allowing me to skip this but can it respect 0.0.0.0 and addresses with * like 10.10.10.*?

Then there was a problem loading assets in APP_ENV=dev from node_modules as this folder is above the document root (docroot).
I have "fixed" this by mounting node_modules inside docroot in docker but this is a hack. Something like

  apache:
    ...
    volumes:
      - ../mautic:/var/www/web
      - ../mautic/node_modules:/var/www/web/docroot/node_modules # fix for node_modules when APP_ENV=dev
    environment:
      - APACHE_DOCUMENT_ROOT=/var/www/web/docroot

Now the APP_ENV=dev sort of works but often throws an error similar to the one below.

Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("PHP Warning - filemtime(): stat failed for /var/www/web/var/cache/de_/AppKernelDevDebugContainer.php"). - in file /app/bundles/CoreBundle/Resources/views/Default/script.html.twig - at line 5

With APP_ENV=dev working like this I am forced to use APP_ENV=prod and basically rm the cache folder whenever I write something and want to check the site.

@escopecz
Copy link
Member

escopecz commented Jun 6, 2024

A composer installation isn't really for development on local. Please use https://www.mautic.org/blog/developer/local-mautic-development-with-ddev instead.

@escopecz escopecz closed this as completed Jun 6, 2024
@iam-sayco
Copy link

@escopecz , I really hope you’re joking about that 😅 I can't think of any other system or framework that suggests not using Composer for local development. It's 2024, not 2004. If we can't use Composer locally, it means something has gone seriously wrong. Ddev is no excuse for that.

@iam-sayco
Copy link

Another thing is that we should re-open the issue and see what the community has to say about it... it's not very inclusive for open projects to shut down discussion so early 🤔 ?

@escopecz escopecz reopened this Jun 6, 2024
@escopecz
Copy link
Member

escopecz commented Jun 6, 2024

Well, in recent years developers should be using Docker Compose (or DDEV for PHP projects) to develop in and of course Git is still a thing. And yes, you'll need Composer to install dependencies either way. However, there are no dev dependencies in this composer.json as it's meant for production. The dev dependencies are here:

https://github.com/mautic/mautic/blob/5.x/composer.json#L27-L48

So you can either follow Mautic's normal development process which is very simple and powerful to use or you can figure out how to use this repository for development. I can see you have a team here so I can't wait what you folks come up with! The issue is open, please disucss.

@pawel-holik-droptica
Copy link
Author

pawel-holik-droptica commented Jun 7, 2024

@escopecz
In the initial message, I have already written:

  • what is missing in composer.json and how to fix it
  • what is the next problem with the IpRestrictMiddleware and how to make it skip the checks (but probably this should be adjusted to compare IPs better)
  • what is the problem with node_modules and how to make it work (I don't have a good solution for this)

Then I hit the wall with the errors throwing when generating the cache, which is why this issue exists.
If I knew how to fix this I would have probably created a PR and not an issue.

I would really appreciate help here.

@escopecz
Copy link
Member

escopecz commented Jun 7, 2024

I understand there are issues when you want to develop on a composer project that is meant for production. I still don't understand why anyone would want to do that when the rest of the community is developing on top of https://github.com/mautic/mautic repository and there is an amazing development environment prepared as well (DDEV). Even Acquia recently went from their custom dev docker environment to DDEV. So please, help us understand the why behind your issue.

@pawel-holik-droptica
Copy link
Author

DDEV and Composer versions have different structures. For example, if I need to patch with the proper composer patch I need to have the composer and be as close to the production as possible.

Also, I am using a company wrapper with all of the tools that we use for stage and production deployment.

On top of this, we have a multi-tenant implementation added that will need different setup and deployment processes when using DDEV.
Using composer we have one process for dev, stage, and prod and I am locally as close to production as possible.

We work like this on every project and have issues only with Mautic.

@escopecz
Copy link
Member

Ok, let's leave this issue open for others with the same needs to come up with the solution for your workflow. I'd look at how the other projects do this and improve this repo or create a new one for recommended-project-development? But that would go against your need to use the same code on all environments.

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

3 participants