Search code examples
phpcrm

EspoCRM : How to create a controller, routing and views/template in html?


I am new to EspoCRM and I find it very cool .. Now I wonder how to develop extensions but cannot find any documentation .. So I tried to check the source code and reproduce and the structure seems well done.

But I cannot find any solutions for this by rednecking around in the source code.

For example if i create a entity named "Quote" in the admin with fields and relations needed

File : custom/Espo/Custom/Controllers/Quote.php

namespace Espo\Custom\Controllers;

class Quote extends \Espo\Core\Controllers\Record  {

    public function actionInvoice($params) {

         die('Hey test dude');

    }

}

File : custom/Espo/Custom/Resources/routes.json

[
  {
      "route":"/Quote/invoice/:id",
       "method":"get",
       "params":{
           "controller":"Quote",
           "action":"invoice",
           "id":":id"
       }
  }
]

When I try to access to my die page "hey test dude" with url : /Quote/invoice/[id_of_invoice] I see error 404 .. I tried to flush all cache and rebuild but it does not work .. Cannot access the page that I have created.

And it is possible too to create HTML template in Resources/layouts/ ? Like for example if I create Quote.html.twig or something ?

Thank you very much and have a great day !!


Solution

  • Try reading the documentation on github:

    https://github.com/espocrm/documentation/blob/master/development/extension-packages.md