ORM Entities not created

Permalink
Hi

I'm currently trying to create a v8 package. But I stuck on creating the tables. On install, the table is not created.

controller.php
<?php
namespace Concrete\Package\SteffTesting;
use \Concrete\Core\Backup\ContentImporter;
class Controller extends \Concrete\Core\Package\Package{
   protected $pkgHandle = 'steff_testing';
   protected $appVersionRequired = '8.5.2';
   protected $pkgVersion = '0.0.28';
   protected $pkgAutoloaderMapCoreExtensions = false;
   protected $pkgAutoloaderRegistries = [
      'src/SteffTesting' => 'SteffTesting'
   ];      
   protected $pkgDescription = 'Testing Package';
   protected $pkgName = 'Testing';
   public function install() {
      $pkg = parent::install();


the entity in steff_testing/src/SteffTesting/Testing/Testing.php starts like this
<?php
namespace SteffTesting\Testing;
use Doctrine\ORM\Mapping as ORM;
/***
 * @ORM\Entity
 * @ORM\Table(name="Testing")
 */
class Testiing{
   /***
    * @ORM\Id 
    * @ORM\Column(type="integer")
    */
    protected $tID;
    public function getTID() { return $this->tID; }
    public function setTID($tID){   $this->tID= $tID; }


Any idea why the database table is not beeing created?

Thanks a lot.
Steff

Steff
 
linuxoid replied on at Permalink Best Answer Reply
linuxoid
Have a look at this package:
https://www.concrete5.org/marketplace/addons/free-simple-comments/...

especially in the package controller, directory structure, namespaces and entity classes... and spelling, e.g.

- I assume 'Testiing' should have been 'Testing'
- The class namespace has to be SteffTesting, not SteffTesting\Testing (when you correct the class name spelling it should throw an error)
- your column 'id' has to match the variable name '$id', not '$tid'
- and don't forget to refresh the entities after installation
public function install()
{
...
    $em = DatabaseORM::entityManager();
    $manager = new DatabaseStructureManager($em);
    $manager->refreshEntities();
...
}
Steff replied on at Permalink Reply
Steff
Tank you linuxoid

This helped me a lot. Where do i have to place the refresh? there are multiple install functions.

Thank you
Kind regards,
Steff
linuxoid replied on at Permalink Reply
linuxoid
I usually refresh the entities in my src/Package_Name/Install/Installer.php in both install() and upgrade() functions. You may as well put it in the package controller's install and upgrade.
Steff replied on at Permalink Reply
Steff
Thank you linuxoid

I always get
Class DatabaseORM not found


I think i have to declare a use .... but couldn't figure it out. Could you please help me again?

Thanks a lot.
linuxoid replied on at Permalink Reply
linuxoid
Steff replied on at Permalink Reply
Steff
thanky linuxoid. This helped me a lot