196 search results

Missed global goal of this lesson - Foundry just help to set database with fake data?
Hey sciro - I'm the creator of foundry. To be clear, the code does work as expected and this is only a PHPStorm warning? I'm also using PHPStorm and I don't see this - what version (of PHPStorm) are you on? The issue is…
Hey Utilisateur The latest version of Foundry allows defining "factories as services" so you now can inject the password encoder service into your `UserFactory`. The example in the docs shows just that. Ryan's suggestion of pre-encoding the password is still my preferred method…
So if I see this right zenstruck/foundry acts as a replacement for the hautelook/AliceBundle dependency which is currently incompatible with api-platform 2.5.7? And is there a reason why zenstruck/foundry and the doctrine-fixtures-bundle isn't just a require…
Taminoful
Taminoful
Read Full Comment
Thank you for the link to Foundy. Will check it out.
sridharpandu
sridharpandu
Read Full Comment
So I tried adding the reset mode migrate to the zenstruck_foundry.yaml ``` when@dev: &dev # See full configuration: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#full-default-bundle-configuration zenstruck_foundry: persistence: # Flush only once per call of `PersistentObjectFactory::create()` flush_once: true…
JeffJones
JeffJones
Read Full Comment
…chapter’s fixture user is created by Foundry, so an empty `user` table usually means the fixtures story never ran, not that Doctrine is broken. Run the story loader explicitly so `AppStory` inserts `picard@enterprise.space` into the database: ```terminal symfony console foundry:load-fixtures ```…
…foundry 2 added a bunch of breaking changes - there is a [migration path for 1.x-2.x](https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.0.md) you can take a look at. In the meantime, no problem staying on foundry 1…
I'm getting some strange deprecation warnings from (it appears: ) foundry: 09:55:55 INFO [deprecation] User Deprecated: Method Doctrine\ORM\Event\LifecycleEventArgs::getEntityManager() is deprecated and will be removed in Doctrine ORM 3.0. Use getObjectManager() instead. (LifecycleEventArgs.php:63 called by ORM.php…
Thanks, i renamed foundry namespace from 'factory' to 'foundry' to keep it seperate from factories that do a better job building non-fixture entities.
I must install this bundle -> `composer require zenstruck/foundry --dev`
pasquale_pellicani
pasquale_pellicani
Read Full Comment
Hi, is it possible to use references in Foundry? Earlier, I used setReference in Fixtures (inherited from AbstractFixture($this->setReference('key', $object))) and could refer to special objects like roles. Does Foundry have a similar feature (getReference('key')) for this case which I can use…
Hey Tien dat L. Foundry is expecting the Question class to have a way to set the tags, in this case it's expecting a public `setTags()` method. Could you check if that method exist? Cheers!
MolloKhan
MolloKhan
Read Full Comment
Hey Brainiac, Yes, Foundry definitely adds more overhead into your project than just simple fixtures, but it also provides more features out of the box. To know more about the features it brings - please, watch this screencast. Also, in the next video we cover some…
// ... lines 1 - 4
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
class LockDownHelperTest extends KernelTestCase
{
use ResetDatabase, Factories;
}
See Code Block in Script
16 lines | tests/Functional/UserResourceTest.php
// ... lines 1 - 2
namespace App\Tests\Functional;
use Zenstruck\Foundry\Test\ResetDatabase;
class UserResourceTest extends ApiTestCase
{
use ResetDatabase;
// ... lines 10 - 14
}
See Code Block in Script
Hey all, this should be fixed in Foundry v1.1.2 (https://github.com/zenstruck/foundry/releases/tag/v1.1.2) - I allow doctrine/persistence v2
54 lines | src/Factory/QuestionFactory.php
// ... lines 1 - 20
final class QuestionFactory extends ModelFactory
{
// ... lines 23 - 35
protected function initialize(): self
{
// see https://github.com/zenstruck/foundry#initialization
return $this
->afterInstantiate(function(Question $question) {
if (!$question->getSlug()) {
// ... lines 42 - 43
}
})
;
}
// ... lines 48 - 52
}
See Code Block in Script
54 lines | src/Factory/QuestionFactory.php
// ... lines 1 - 20
final class QuestionFactory extends ModelFactory
{
// ... lines 23 - 40
protected function initialize(): self
{
// see https://github.com/zenstruck/foundry#initialization
return $this
//->afterInstantiate(function(Question $question) { });
;
}
// ... lines 48 - 52
}
See Code Block in Script
…data fixtures just create factories or load stories. It was the only method to do so for many years. Foundry's load-fixtures command is relatively new. We added it because requiring doctrine fixtures brings a lot of unused code just to load foundry factories.