PHP code example of lyssal / geographie-bundle

1. Go to this page and download the library: Download lyssal/geographie-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/ */

    

lyssal / geographie-bundle example snippets


namespace Acme\GeographieBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeGeographieBundle extends Bundle
{
    public function getParent()
    {
        return 'LyssalGeographieBundle';
    }
}

namespace Acme\GeographieBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Lyssal\GeographieBundle\Entity\Pays as BasePays;
use Doctrine\ORM\Mapping\UniqueConstraint;

/**
 * Pays du monde.
 * 
 * @ORM\Entity()
 * @ORM\Table
 * (
 *     name="acme_pays",
 *     uniqueConstraints=
 *     {
 *         @UniqueConstraint(name="CODE_ALPHA_2", columns={ "pays_code_alpha_2" }),
 *         @UniqueConstraint(name="CODE_ALPHA_3", columns={ "pays_code_alpha_3" })
 *     }
 * )
 */
class Pays extends BasePays
{
    /**
     * @var array<\Acme\GeographieBundle\Entity\Region>
     * 
     * @ORM\OneToMany(targetEntity="Region", mappedBy="pays")
     */
    protected $regions;
}

namespace Acme\GeographieBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Lyssal\GeographieBundle\Entity\Region as BaseRegion;

/**
 * Région d'un pays.
 * 
 * @ORM\Entity()
 * @ORM\Table(name="acme_region")
 */
class Region extends BaseRegion
{
    /**
     * @var \Acme\GeographieBundle\Entity\Pays
     * 
     * @ORM\ManyToOne(targetEntity="Pays", inversedBy="regions")
     * @ORM\JoinColumn(name="pays_id", referencedColumnName="pays_id", nullable=false, onDelete="CASCADE")
     */
    protected $pays;
    
    /**
     * @ORM\OneToMany(targetEntity="Departement", mappedBy="region")
     */
    protected $departements;
}

namespace Acme\GeographieBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Lyssal\GeographieBundle\Entity\Departement as BaseDepartement;
use Doctrine\ORM\Mapping\UniqueConstraint;

/**
 * Département d'une région.
 * 
 * @ORM\Entity(repositoryClass="\Lyssal\GeographieBundle\Repository\DepartementRepository")
 * @ORM\Table
 * (
 *     name="acme_departement",
 *     uniqueConstraints=
 *     {
 *         @UniqueConstraint(name="REGION_CODE", columns={ "region_id", "departement_code" })
 *     }
 * )
 */
class Departement extends BaseDepartement
{
    /**
     * @var \Acme\GeographieBundle\Entity\Region
     * 
     * @ORM\ManyToOne(targetEntity="Region", inversedBy="departements")
     * @ORM\JoinColumn(name="reg_id", referencedColumnName="reg_id", nullable=false, onDelete="CASCADE")
     */
    protected $region;
    
    /**
     * @var array<\Acme\GeographieBundle\Entity\Ville>
     * 
     * @ORM\OneToMany(targetEntity="Ville", mappedBy="departement")
     */
    protected $villes;
}

namespace Acme\GeographieBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Lyssal\GeographieBundle\Entity\Ville as BaseVille;

/**
 * Ville.
 * 
 * @ORM\Entity()
 * @ORM\Table(name="acme_ville")
 */
class Ville extends BaseVille
{
    /**
     * @var \Acme\GeographieBundle\Entity\Departement
     * 
     * @ORM\ManyToOne(targetEntity="Departement", inversedBy="villes")
     * @ORM\JoinColumn(name="dep_id", referencedColumnName="dep_id", nullable=false, onDelete="CASCADE")
     */
    protected $departement;
}

namespace Acme\GeographieBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Lyssal\GeographieBundle\Entity\CodePostal as BaseCodePostal;

/**
 * Code postal.
 * 
 * @ORM\Entity()
 * @ORM\Table(name="acme_code_postal", uniqueConstraints={@ORM\UniqueConstraint(name="UNIQUE_VILLE_CODE", columns={"ville_id", "code_postal_code"})})
 */
class CodePostal extends BaseCodePostal
{
    
}

namespace Acme\GeographieBundle\Entity;

use Lyssal\GeographieBundle\Entity\Langue as BaseLangue;
use Doctrine\ORM\Mapping as ORM;

/**
 * Langue.
 * 
 * @ORM\Entity()
 * @ORM\Table(name="acme_langue")
 */
class Langue extends BaseLangue
{
    
}

new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),

$tousLesPays = $this->container->get('lyssal.geographie.manager.pays')->findAll();

new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new Lyssal\StructureBundle\LyssalStructureBundle(),
new Lyssal\GeographieBundle\LyssalGeographieBundle(),
new Acme\GeographieBundle\AcmeGeographieBundle(),
sh
php composer.phar update