-
Notifications
You must be signed in to change notification settings - Fork 7
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
Autoloading issues #56
Comments
Ah, so is it a matter where ddd autoloading should be ignoring the test directory if there is one? And therefore be able to configure a designated domain test folder to ignore. Or more generally, maybe a configurable
I see, I remember this kind of behaviour back when Laravel wasn't using anonymous classes yet for migrations. That being said, are you generating migrations inside the domain layer then, hence why it gets picked up by
|
Yes, some kind of general solution like an configurable ignore would be great. An array with paths inside each Domain(relative to domain root) that should be ignored would work. Something like this:
I did not see any support for this in Lody, but it should be possible to do this with a custom finder filter.
Yes, I like to put migrations, factories and seeders inside the domain they belong to. The ignore could be used to solve this as well 👍 |
I wonder if Being able to bundle in tests and migrations would make the domain fully portable and copy-paste-able from one app to another at that point. |
That would be great.
Yes, that package provides an
I'm working on a product company with a single Laravel project so that is not my primary reason, but if you are working with multiple projects I could imagine that would be would be very handy. |
Yeah, the portable-domain scenario is well suited for those who build multiple apps for various clients (such as me). I will work on these updates over the weekend. |
Great, thanks a lot! I was able to filter out the tests using this code:
So, something like that would work. Another idea that I think would be great is support for something like this to provide your own filter callback like this in your service provider:
Then you could implement your own logic for this and not just and array of simple startsWith strings. |
I cloned the repo and ran Everything works if I do a |
...however, I was able to simulate the conflicting migration classes scenario through the package tests, so I can move forward with an |
I've been tinkering with this, and some challenges I'm facing at the moment: For the non-psr migrations residing inside the domain issue, if I understand correctly, this is a violation at the composer level, since everything under For the |
Hello again!
I'm having some issues with the autoloading. Primarily when deploying the code.
I like to put my related tests inside my domains (a command for generating tests would be great by the way), but that generates problems with the autoloading. The tests are only autoloaded when composer includes dev dependencies. But since the
ddd:cache
command touches all files in the domain directory, this generates problems because the base test case is not autoloaded and thus I get this error:Class "Tests\TestCase" not found
when runningddd:cache
.I created a repo where I demonstrate this problem here: https://github.com/pelmered/laravel-test-ddd
Just clone, run
composer install --no-dev
and then runddd:cache
to reproduce the problem.I have also had problems with some other things, for example the migrations from babenkoivan/elastic-migrations. That package creates migrations with the same file format as the default Laravel migrations, but they also include a class name so they are not PSR autoload compliant. Here is how they look. When autoloading or running
ddd:cache
these files are included several times and therefore gives this kind of error:Cannot declare class CreateUsersIndex, because the name is already in use
. I created a PR there to use anonymous classes, just like Laravels migrations, here.As you can see, this is a general problem that probably needs to be addressed in this package in some way.
What do you think is the best way forward? Let me know if I can be of assistance.
Other than this, I'm happy to report that it worked very well in our application and that the transition was very smooth to start using the autoload provided in this package.
The text was updated successfully, but these errors were encountered: