bolt / core

🧿 Bolt 5 core
https://boltcms.io
MIT License
542 stars 159 forks source link

make:controller command creates the templates in the vendor folder #2259

Open severin-bruhat opened 3 years ago

severin-bruhat commented 3 years ago

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

bobdenotter commented 3 years ago

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

severin-bruhat commented 3 years ago

Sure, I have updated it.

LordSimal commented 3 years ago

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
I-Valchev commented 3 years ago

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.

LordSimal commented 3 years ago

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.

celtic34fr commented 1 year ago

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 commented 11 months ago

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.