CakePHP 4 policy missing from cake bake command

by | Jun 1, 2022 | IT Tips | 0 comments

If you try the bin/cake bake policy command and get "Could not find a task named policy."

1
2
bin/cake bake policy
Could not find a task named `policy`.

Make sure CakePHP Authorization is installed and then add the following to src/Application.php

1
2
3
4
5
6
7
8
9
10
11
12
public function bootstrap(): void
{
    // Call parent to load bootstrap from files.
    parent::bootstrap();
 
    // other code here
 
    // Load more plugins here
 
  
    $this->addPlugin('Authorization');
}

Try again and you are good to go

1
2
3
4
5
6
7
8
9
10
bin/cake bake policy
# output
You must provide a name to bake a policy
 
 
bin/cake bake policy DebugKitAuthBypass     
 
#output
Creating file C:\dev\cake-auth\src\Policy\DebugKitAuthBypassPolicy.php
Wrote `C:\dev\cake-auth\src\Policy\DebugKitAuthBypassPolicy.php`

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.