vierge-noire / cakephp-fixture-factories

CakePHP Fixture Factories
https://vierge-noire.github.io/
MIT License
83 stars 21 forks source link

Template file `No bake template found for "fixture_factory" skipping file generation.` could not be found #2

Closed LordSimal closed 4 years ago

LordSimal commented 4 years ago

What is the error?

bin/cake bake fixture_factory -a -f
Exception: Template file `No bake template found for "fixture_factory" skipping file generation.` could not be found.
In [No bake template found for "fixture_factory" skipping file generation., line 104]

2020-05-01 11:19:41 Error: [Cake\View\Exception\MissingTemplateException] Template file `No bake template found for "fixture_factory" skipping file generation.` could not be found. in No bake template found for "fixture_factory" skipping file generation. on line 104
Exception Attributes: array (
  'file' => 'No bake template found for "fixture_factory" skipping file generation.',
  'paths' => 
  array (
  ),
)
Stack Trace:
- <my-path>/vendor/pakacuda/cakephp-fixture-factories/src/Command/FixtureFactoryCommand.php:198
- <my-path>/vendor/pakacuda/cakephp-fixture-factories/src/Command/FixtureFactoryCommand.php:139
- <my-path>/vendor/pakacuda/cakephp-fixture-factories/src/Command/FixtureFactoryCommand.php:168
- <my-path>/vendor/cakephp/cakephp/src/Console/BaseCommand.php:175
- <my-path>/vendor/cakephp/cakephp/src/Console/CommandRunner.php:336
- <my-path>/vendor/cakephp/cakephp/src/Console/CommandRunner.php:171
- <my-path>/bin/cake.php:12

What did I do?

composer require --dev pakacuda/cakephp-fixture-factories  

This successfully added the plugin to the vendor

composer require --dev pakacuda/cakephp-fixture-factories    
Using version ^0.2.4 for pakacuda/cakephp-fixture-factories
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing fzaninotto/faker (v1.9.1): Downloading (100%)         
  - Installing pakacuda/cakephp-fixture-factories (v0.2.4): Downloading (100%)         
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
17 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Then i manually added the Plugin into the bootstrapCli() function in the src/Application.php

$this->addPlugin('CakephpFixtureFactories');

After that I executed

bin/cake bake fixture_factory -a -f   

For me it seems like it can't find the vendor/pakacuda/cakephp-fixture-factories/templates/bake/fixture_factory.twig even though it is present.

My composer.json ``` { "name": "cakephp/app", "description": "CakePHP skeleton app", "homepage": "https://cakephp.org", "type": "project", "license": "MIT", "require": { "php": ">=7.2", "ext-curl": "*", "ext-ftp": "*", "ext-json": "*", "cakephp/cakephp": "^4.0", "cakephp/migrations": "3.0.0-beta2", "cakephp/plugin-installer": "^1.0", "gamez/mite": "^1.0", "guzzlehttp/guzzle": "^6.5", "jeroendesloovere/vcard": "^1.7", "mobiledetect/mobiledetectlib": "2.*", "phan/phan": "^2.4", "phpoffice/phpspreadsheet": "^1.9" }, "require-dev": { "cakephp/bake": "^2.0", "cakephp/cakephp-codesniffer": "dev-next", "cakephp/debug_kit": "^4.0", "dereuromark/cakephp-ide-helper": "^1.5", "easybill/php-sdk": "^2.0", "josegonzalez/dotenv": "3.*", "pakacuda/cakephp-fixture-factories": "^0.2.4", "phpseclib/phpseclib": "^2.0", "phpunit/phpunit": "^8.0", "psy/psysh": "@stable" }, "suggest": { "markstory/asset_compress": "An asset compression plugin which provides file concatenation and a flexible filter system for preprocessing and minification.", "dereuromark/cakephp-ide-helper": "After baking your code, this keeps your annotations in sync with the code evolving from there on for maximum IDE and PHPStan compatibility." }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Test\\": "tests/", "Cake\\Test\\": "vendor/cakephp/cakephp/tests/" } }, "scripts": { "post-install-cmd": "App\\Console\\Installer::postInstall", "post-create-project-cmd": "App\\Console\\Installer::postInstall", "post-autoload-dump": "Cake\\Composer\\Installer\\PluginInstaller::postAutoloadDump", "check": [ "@test", "@cs-check" ], "cs-check": "phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/", "cs-fix": "phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/", "stan": "phpstan analyse src/", "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan-shim:^0.11 && mv composer.backup composer.json", "test": "phpunit --colors=always" }, "prefer-stable": true, "config": { "sort-packages": true }, "minimum-stability": "dev" } ```
My phpunit.xml ``` tests/TestCase/ tests/TestCase/Database/ tests/TestCase/ORM/ tests/TestCase/DatabaseSuite.php src/ src/basics.php src/Core/ClassLoader.php ```
LordSimal commented 4 years ago

As you can see in my composer.json in the Issue I use cakephp/cakephp:^4.0

To be specific I use 4.0.6

Von: webrider notifications@github.com Gesendet: Freitag, 1. Mai 2020 15:47 An: pakacuda/cakephp-fixture-factories cakephp-fixture-factories@noreply.github.com Cc: Kevin Pfeifer info@pfiff.me; Author author@noreply.github.com Betreff: Re: [pakacuda/cakephp-fixture-factories] Template file No bake template found for "fixture_factory" skipping file generation. could not be found (#2)

Hi,

thanks for giving it a try. Are you using CakePHP 3.x or 4.x?

For 3.x use "^0.1.0", 4.x use "^0.2.0"

I'll update the documentation.

Let me know if this fixed you issue!

pabloelcolombiano commented 4 years ago

@LordSimal indeed, I saw only after that you had given your full composer.

Well first thanks for trying out the vendor, and for your feedback. I have applied a fix. Would you mind trying again by reinstalling the vendor?

LordSimal commented 4 years ago

Since composer needs some time to update I just applied your change in the vendor/pakacuda/cakephp-fixture-factories/src/Command/FixtureFactoryCommand.php manually and now the command works and the factories got generated!

Thanks for that quick fix!

PS: I found your repository because you were in the "CakePHP Online Meetup 2020-04 with Mark Scherer" stream 😄 And since I have a CakePHP project with 44 tables and basically no testing I was quite intrigued by your factory.