core icon indicating copy to clipboard operation
core copied to clipboard

make:controller command creates the templates in the vendor folder

Open severin-bruhat opened this issue 5 years ago • 8 comments

Hi,

Details

Relevant Bolt Version | 4.1.9 Install type | Composer install BC Break | yes/no ??? PHP version | 7.3 Web server | built in

Reproduction

Run bin/console make:controller and create a controller

Actual result

created: src/Controller/CarController.php
created: vendor/bolt/core/templates/car/index.html.twig

I was not expecting my template to go into the vendor folder. Is this normal?

Thank you

severin-bruhat avatar Dec 21 '20 22:12 severin-bruhat

Please update this issue with the information from the issue template, which we've carefully put together and you have deftly removed.

bobdenotter avatar Dec 22 '20 07:12 bobdenotter

Sure, I have updated it.

severin-bruhat avatar Dec 22 '20 09:12 severin-bruhat

I can confirm this problem

boltcms@home [03:32:07 PM] [~/httpdocs]
-> % bin/console make:controller

 Choose a name for your controller class (e.g. BraveGnomeController):
 > MyTestController

 created: src/Controller/MyTestController.php
 created: vendor/bolt/core/templates/my_test/index.html.twig


  Success!


 Next: Open your new controller class and add some pages!
 
-> % bin/console bolt:info

⚙️  Bolt
========

 Bolt version: 4.1.9

 * Install type: Composer install
 * Database: mysql 5.5.5-10.5.8-MariaDB-1:10.5.8+maria~focal - Localhost via UNIX socket (with JSON)
 * PHP version: 7.4.13
 * Symfony version: v5.2.1
 * Operating System: Linux - 5.4.0-56-generic

LordSimal avatar Dec 30 '20 14:12 LordSimal

Hi @LordSimal and @severin-bruhat ,

This could be because we required the maker bundle in bolt/core itself, instead of bolt/project.

Following discussion and a PR, from Bolt 4.2 onwards we'll not include the bundle by default. You'd still be able to install and use the bin/console make:... commands in Bolt projects, however. I assume it will resolve the issue with the wrong destination folder as well.

I-Valchev avatar Jan 12 '21 16:01 I-Valchev

If the maker bundle is not required for anything "directly" bolt related I also think, that making it "optional" (and therefore a user requested dependency in the apps composer.json) is the better way.

LordSimal avatar Jan 12 '21 16:01 LordSimal

hi everyone,

Using Bolt CMS 5.1.*, I have the same behavior. But when I try to change the default folder use for searching template, I've got some troubles. If the using theme don't refer to the good Twig namespace, Bolt can't generate the page. If you want to make work, you must prefix all include by '@bolt/' or '@theme' according of the context and make sure that all asset refer the good file in the good place. I have this behavior with theme-2021 first.

Gilbert ARMENGAUD celtic34fr Béziers, Occitanie, France.

celtic34fr avatar May 31 '23 07:05 celtic34fr

Additional information using Bolt CMS 5.1.*: -> The application sets the default templates folder in config/packages/twig.yaml under the 'default_path' paragraph. If you go to the templates folder of your applications, it is impossible to connect to the backend: all the target files don't refer to @bolt (default bolt templates folder) nor to @theme (current theme folder), it works with a relative path.

As I said in my previous observation, and to put it in good practice, all templates used by Bolt CMS must reference for any include, import or asset to the correct necessary path with the prefix @bolt/ or @theme /. With this, I can use Symfony's make tool to create all the application controller templates in the right place after changing the 'default_path' value in the twig.yaml file. Now I need to search in the Bolt Cms base models folder for the new folder created for my new controller and move it the right place (the controller file is in the right place though).

Gilbert ARMENGAUD celtic34fr Béziers, Occitanie, France.

celtic34fr avatar Oct 19 '23 12:10 celtic34fr