1. Go to this page and download the library: Download okvpn/fixture-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
okvpn / fixture-bundle example snippets
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Okvpn\Bundle\FixtureBundle\OkvpnFixtureBundle(),
//...
);
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
}
// src/Akuma/PassBundle/Migrations/Data/ORM/TestFixture.php
namespace Akuma\PassBundle\Fixture\Data;
use Akuma\PassBundle\Entity\Item;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
class TestFixture extends AbstractFixture
{
public function load(ObjectManager $manager)
{
$item = new Item();
$item->setHumidity(58.00)
->setTemp(10.8)
->setPressure(1019.23)
->setTimestamp(new \DateTime());
$manager->persist($item);
$manager->flush();
}
}
php
namespace Acme\DemoBundle\Migrations\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;
use Okvpn\Bundle\FixtureBundle\Fixture\VersionedFixtureInterface;
class LoadSomeDataFixture extends AbstractFixture implements VersionedFixtureInterface
{
/**
* {@inheritdoc}
*/
public function getVersion()
{
return '1.0';
}
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
// Here we can use fixture data code which will be run time after time
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.