hounddog / doctrinedatafixturemodule Goto Github PK
View Code? Open in Web Editor NEWDoctrine Data Fixture Module for Zf2 with cli integration
License: BSD 2-Clause "Simplified" License
Doctrine Data Fixture Module for Zf2 with cli integration
License: BSD 2-Clause "Simplified" License
Hi,
the new DoctrineORMModule is released since some time now to version 1.0.0 (https://github.com/doctrine/DoctrineORMModule/releases/tag/1.0.0).
I will really like to use your module with the DoctrineORMModule 1.0.0 but the composer Required ~0.7 is set a little bit low:
THX!
Idea is stolen from Symfony 2. You can make fixtures implement the Zend\ServiceManager\ServiceLocatorAwareInterface
and then you get the service manager injected. It might come in handy if some fixtures needs to be "processed" where the logic is already defined in one of your services.
Hello,
The configuration for Registering Fixtures
return array(
'data-fixture' => array(
'ModuleName_fixture' => __DIR__ . '/../src/ModuleName/Fixture',
)
);
does not work and the fixtures files are not loaded. It should be
return array(
'doctrine' => array(
'fixture' => array(
'ModuleName_fixture' => __DIR__ . '/../src/ModuleName/Fixture',
)
),
);
and then everything works fine.
Please update the documentation :)
Thanks!
Would be a nice thing to use configuration to create objects. I would suggest to test, if a Fixture implements ServiceLocatorAwareInterface and set its ServiceLocator before running execute. I can add a PR when I have a bit more time.
Implement a switch or new Command to append fixtures instead of purging and inserting
The documentation says:
$ php composer.phar require hounddog/doctrine-data-fixture-module:0.0.*
Using this command composer will require tag 0.0.4. In that version the configuration is not fetched like the documentation explains.
DoctrineDataFixtureModule\Service\FixtureFactory on 0.0.4
public function getOptions(ServiceLocatorInterface $sl, $key)
{
$options = $sl->get('Configuration');
if (!isset($options['data-fixture'])) {
return array();
}
return $options['data-fixture'];
}
DoctrineDataFixtureModule\Service\FixtureFactory on master
public function getOptions(ServiceLocatorInterface $sl, $key)
{
$options = $sl->get('config');
if (!isset($options['doctrine']['fixture'])) {
return array();
}
return $options['doctrine']['fixture'];
}
So after following the documentation for installation and configuration you will end up with a command that will not load any fixtures.
Hi all,
is there any way to share object between fixtures. I see ObjectManager have getReference method, but no addReference.
Basically I would like to use some objects in subsequent fixtures...
Thanks.
Yesterday you merged the PR #10, but this update is not yet available to users.
You need to update the module in Packagist.
To do this there are 2 ways:
Force update
here"Enabling the Packagist service hook ensures that your package will always be updated instantly when you push to GitHub. To do so you can go to your GitHub repository, click the "Admin" button, then "Service Hooks". Pick "Packagist" in the list, and add your API token (see above), plus your Packagist username if it is not the same as on GitHub. Check the "Active" box and submit the form."
REF: #33
This issue has not resolved.
If you setup the module as in the documentation, the import does not work because within Module.php
$paths = $sm->get('doctrine.configuration.fixtures');
returns an empty array. What actually works is $config = $sm->get('Config'); $paths = $config['data-fixture'];
if you adhere to the documentation.
The solution is either update Module.php or update the documentation from
return [
'data-fixture' => [
'ModuleName_fixture' => __DIR__ . '/../src/ModuleName/Fixture',
]
];
to
return [
'doctrine' => [
'fixture' => [
'ModuleName_fixture' => __DIR__ . '/../src/ModuleName/Fixture',
]
],
];
Running "data-fixture:import" doesn't do anything for me so I've tracked the problem down to FixtureFactory, which fails to getOptions (empty array returned).
I've noticed that "get('config')" doesn't return keys ['doctrine']['fixture'] so an empty array gets returned on this line: https://github.com/Hounddog/DoctrineDataFixtureModule/blob/master/src/DoctrineDataFixtureModule/Service/FixtureFactory.php#L56 and no fixtures classes are executed.
UPDATE: Sorry, my bad...I've found a config file cached inside vendor folder. Removing cache fixed it.
When i try to purge data with purge-with-truncate option before insert fixtures, i have a SQL error :
[Doctrine\DBAL\DBALException]
An exception occurred while executing 'TRUNCATE table':
SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint (`database`.`table`, CONSTRAINT `FK_E75F52F596D36FD` FOREIGN KEY (`foreign_key`) REFE
RENCES `database`.`table2` (`id`))
Dear all,
As I don't like to extend my minimum-stability to dev, do you think it's feasable to create ร 0.02 version of this package ?
I think this would be valuable as some dependencies have been updated since the last version :)
Thanks a lot,
Greg
If you have multiple entity managers, it would be nice to be able to specify your secondary manager with a flag. For instance --em=orm_secondary
. The name equals the key in the doctrine module configuration (where the default one is orm_default
).
I tried to use your module with zf 2.3.2dev and when I execute the import command the module delete all my data but, doesn't create anything, that because the command:
$paths = $sm->get('doctrine.configuration.fixtures');
in Module.php doesn't work.
Just change it with:
$config = $sm->get('Config');
$paths = $config['doctrine']['configuration']['fixtures'];
and please change the documentation for the reference of fixture paths.
Move the module configuration options to the 'doctrine' key
doctrine/data-fixtures supports the mongodb ODM as well as the ORM.
Currently the composer.json file requires the ORM which causes the ORM to download even if I don't use it, but uses the ODM.
Currently we can only specify a Directory path to the fixtures. We should also be able to specify each fixture as single entities.
Require section of my composer.json is like below:
"require": {
"php": ">=5.6",
"zendframework/zendframework": "2.4.0",
"doctrine/orm": "2.5.0",
"doctrine/doctrine-module": "dev-master",
"doctrine/doctrine-orm-module": "dev-master",
"hounddog/doctrine-data-fixture-module": "dev-master"
},
and composer update command produces this output:
$ php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- hounddog/doctrine-data-fixture-module dev-master requires doctrine/doctrine-orm-module ~0.7 -> no matching package found.
- hounddog/doctrine-data-fixture-module dev-master requires doctrine/doctrine-orm-module ~0.7 -> no matching package found.
- Installation request for hounddog/doctrine-data-fixture-module dev-master -> satisfiable by hounddog/doctrine-data-fixture-module[dev-master].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Currently its impossible to install DoctrineDataFixtureModule and DoctrineORMModule together.
How to inject service manager into data fixture. ServiceLocatorAwareInterface doesn't work
<?php
namespace Application\Fixture;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use StaticBlock\Entity\StaticBlock;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class AddressFixture implements FixtureInterface, ServiceLocatorAwareInterface
{
protected $serviceLocator;
public function load(ObjectManager $manager)
{
if ($this->getServiceLocator()) {
die('woohoo there is servicelocator');
}
var_dump($this->getServiceLocator());
// ... personal stuff cut out
}
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
var_dump('hello assigning service locator');
$this->serviceLocator = $serviceLocator;
}
public function getServiceLocator()
{
return $this->serviceLocator;
}
}
This module ignores the --em=orm_alterante
flag provided by SwissEngine/Doctrine-Module-Extension
.
After a little debugging this is because the EntityManager is set in the "loadCli.post" event, before the CLI Helper even is made aware of the alternate EntityManager.
I have come up with a quick hack of a solution: Load the EntityManager from the CLI Helper inside the execute() { }
function
ie, change:
public function execute(InputInterface $input, OutputInterface $output)
{
$loader = new ServiceLocatorAwareLoader($this->serviceLocator);
$purger = new ORMPurger();
// etc...
to:
public function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getHelper('em')->getEntityManager();
$this->setEntityManager($em);
$loader = new ServiceLocatorAwareLoader($this->serviceLocator);
$purger = new ORMPurger();
// etc ....
I try to instal in my zf2 2.2.2 and this error apeared:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for hounddog/doctrine-data-fixture-module dev-master -> satisfiable by hounddog/doctrine-data-fixture-module dev-master.
- hounddog/doctrine-data-fixture-module dev-master requires doctrine/data-fixtures dev-master -> no matching package found.
Potential causes:
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
Installation failed, reverting composer.json to its original content.
What i need to do??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.