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

Mention loading fixtures via symfony console command in README #18

Merged
merged 6 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ final class MyCustomTest extends BaseKernelTestCase
}
```

To load fixtures in your local environment or as part of a deployment two commands are provided:
- `neusta:pimcore-fixture:load` (Loads a defined fixture class.)
- `neusta:pimcore-fixtures:load` (Loads all defined fixture classes.)

Beware that loading a large amount of objects may lead to a high consumption of memory.
Should you encounter memory issues when running the commands in `dev` environments you may want to try
setting the environment to `prod`. This appears to be beneficial in terms of pimcore's memory consumption.

### Accessing Services from the Fixtures

As the Fixtures are just normal PHP Services you can use all DI features like constructor, setter or property injection as usual.
Expand Down
7 changes: 7 additions & 0 deletions src/EventListener/PimcoreLoadOptimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Neusta\Pimcore\FixtureBundle\EventListener;

use Doctrine\DBAL\Logging\SQLLogger;
use Neusta\Pimcore\FixtureBundle\Event\AfterExecuteFixture;
use Neusta\Pimcore\FixtureBundle\Event\AfterLoadFixtures;
use Neusta\Pimcore\FixtureBundle\Event\BeforeLoadFixtures;
use Pimcore\Cache;
Expand All @@ -29,6 +30,7 @@ public static function getSubscribedEvents(): array
return [
BeforeLoadFixtures::class => 'beforeCommand',
AfterLoadFixtures::class => 'afterCommand',
AfterExecuteFixture::class => 'afterExecute',
];
}

Expand All @@ -52,4 +54,9 @@ public function afterCommand(): void
$this->versionEnabled && Version::enable();
$this->cacheEnabled && Cache::enable();
}

public function afterExecute(): void
{
\Pimcore::collectGarbage();
jdreesen marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading