Code Generation with Bake

    • You have the PHP CLI installed and that it has the proper modules enabled (eg: MySQL, intl).
    • Users also might have issues if the database host is ‘localhost’ and should try ‘127.0.0.1’ instead, as localhost can cause issues with PHP CLI.
    • Depending on how your computer is configured, you may have to set execute rights on the cake bash script to call it using .
      Before running bake you should make sure you have at least one databaseconnection configured. See the section on database configuration for more information.

    When run with no arguments will output a list of availabletasks.

    You should see something like:

    1. $ bin/cake bake --help
    2.  
    3. Welcome to CakePHP v3.4.6 Console
    4. ---------------------------------------------------------------
    5. App : src
    6. Path: /var/www/cakephp.dev/src/
    7. PHP : 5.6.20
    8. ---------------------------------------------------------------
    9. The Bake script generates controllers, models and template files for
    10. your application. If run with no command line arguments, Bake guides the
    11. user through the class creation process. You can customize the
    12. generation process by telling Bake where different parts of your
    13. application are using command line arguments.
    14.  
    15. Usage:
    16. cake bake.bake [subcommand] [options]
    17.  
    18.  
    19. all Bake a complete MVC skeleton.
    20. behavior Bake a behavior class file.
    21. cell Bake a cell class file.
    22. component Bake a component class file.
    23. controller Bake a controller skeleton.
    24. fixture Generate fixtures for use with the test suite. You
    25. can use `bake fixture all` to bake all fixtures.
    26. form Bake a form class file.
    27. helper Bake a helper class file.
    28. mailer Bake a mailer class file.
    29. migration Bake migration class.
    30. migration_diff Bake migration class.
    31. migration_snapshot Bake migration snapshot class.
    32. model Bake table and entity classes.
    33. plugin Create the directory structure, AppController class
    34. and testing setup for a new plugin. Can create
    35. plugins in any of your bootstrapped plugin paths.
    36. seed Bake seed class.
    37. shell Bake a shell class file.
    38. shell_helper Bake a shell_helper class file.
    39. template Bake views for a controller, using built-in or
    40. custom templates.
    41. test Bake test case skeletons for classes.
    42.  
    43. To see help on a subcommand use `cake bake.bake [subcommand] --help`
    44.  
    45. Options:
    46.  
    47. --connection, -c Database connection to use in conjunction with `bake
    48. all`. (default: default)
    49. --everything Bake a complete MVC skeleton, using all the available
    50. tables. Usage: "bake all --everything"
    51. --force, -f Force overwriting existing files without prompting.
    52. --help, -h Display this help.
    53. --plugin, -p Plugin to bake into.
    54. --prefix Prefix to bake controllers and templates into.
    55. --quiet, -q Enable quiet output.
    56. --tablePrefix Table prefix to be used in models.
    57. --theme, -t The theme to use when baking code. (choices:
    58. Bake|Migrations)
    59. --verbose, -v Enable verbose output.

    The theme option is common to all bake commands, and allows changing the baketemplate files used when baking. To create your own templates, see the.