{"id":16731513,"url":"https://github.com/arodu/utilcake","last_synced_at":"2026-05-20T06:07:56.080Z","repository":{"id":62487700,"uuid":"277391511","full_name":"arodu/utilcake","owner":"arodu","description":"UtilCake plugin for CakePHP 4.x","archived":false,"fork":false,"pushed_at":"2020-11-29T21:13:23.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T08:10:55.514Z","etag":null,"topics":["cakephp","cakephp4","composer","google-login","plugin","recaptcha-v3","utilcake-plugin","utilities"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/arodu/utilcake","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arodu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-05T22:11:34.000Z","updated_at":"2023-06-27T01:19:30.000Z","dependencies_parsed_at":"2022-11-02T10:02:55.744Z","dependency_job_id":null,"html_url":"https://github.com/arodu/utilcake","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodu%2Futilcake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodu%2Futilcake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodu%2Futilcake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arodu%2Futilcake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arodu","download_url":"https://codeload.github.com/arodu/utilcake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243771128,"owners_count":20345406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","cakephp4","composer","google-login","plugin","recaptcha-v3","utilcake-plugin","utilities"],"created_at":"2024-10-12T23:37:39.975Z","updated_at":"2026-05-20T06:07:56.034Z","avatar_url":"https://github.com/arodu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UtilCake plugin for CakePHP 4.x\n\nCakePHP Plugin, collection of utilities for CakePHP 4.x\n\n## Installation\n\nYou can install this plugin into your CakePHP application using [composer](https://getcomposer.org).\n\nThe recommended way to install composer packages is:\n\n```sh\ncomposer require arodu/utilcake\n```\n\n## Configuration\n\nYou can load the plugin using the shell command:\n\n```sh\nbin/cake plugin load UtilCake\n```\n\nOr you can manually add the loading statement in the **src/Application.php** file of your application:\n\n```php\npublic function bootstrap(){\n    parent::bootstrap();\n    $this-\u003eaddPlugin('UtilCake');\n}\n```\n\n## How to use\n\n### Google reCaptcha V3\n\nIn the controller file\n\n```php\npublic function initialize(): void{\n  parent::initialize();\n  $this-\u003eloadComponent('UtilCake.ReCaptcha', [\n    'public_key'=\u003e'RECAPTCHA_PUBLIC_KEY',\n    'secret_key'=\u003e'RECAPTCHA_SECRET_KEY',\n  ]);\n}\n\n// any action\npublic function action(){\n  // ...\n  if ($this-\u003erequest-\u003eis('post')) {\n    if($this-\u003eReCaptcha-\u003everify($this-\u003erequest-\u003egetData())){\n      // when the verification is successful\n      // ...\n    }else{\n      // when the verification is not successful\n      $this-\u003eFlash-\u003eerror(__('reCaptcha failed, try again'));\n    }\n  }\n  // ...\n}\n```\n\nIn the template `templates/ControllerName/action.php`\n\n```php\necho $this-\u003eForm-\u003ecreate(null, ['id'=\u003e'form-id']);\n  // ...\necho $this-\u003eForm-\u003eend();\n\n$this-\u003eReCaptcha-\u003escript('#form-id');\n```\n\n### Google login\n\nwith AuthenticationComponent\n\nIn the login template, ex:`/templates/Users/login.php`\n\n```php\necho $this-\u003eGoogleLogin-\u003elink(__('Sign in with Google'),\n  ['class' =\u003e 'btn btn-block btn-danger', 'escape' =\u003e false]\n);\n```\n\nIn the controller file, ex:`/Controller/UsersController.php`\n\n```php\npublic function initialize(): void{\n  parent::initialize();\n  $this-\u003eloadComponent('UtilCake.GoogleLogin', [\n    'client_id' =\u003e GOOGLE_CLIENT_ID,\n    'client_secret' =\u003e GOOGLE_CLIENT_SECRET,\n    'redirect_uri' =\u003e Router::url([\n        'controller' =\u003e 'Users',\n        'action' =\u003e 'googleLogin',\n        'prefix' =\u003e false,\n        '_full' =\u003e true\n      ]),\n  ]);\n}\n\n//...\n\npublic function googleLogin() {\n  if (!empty($this-\u003erequest-\u003egetQuery('code'))) {\n    try {\n      $data = $this-\u003eGoogleLogin-\u003egetAccessToken($this-\u003erequest-\u003egetQuery('code'));\n      $user_profile_info = $this-\u003eGoogleLogin-\u003egetUserProfileInfo($data['access_token']);\n\n      $user = $this-\u003eUsers-\u003efind()\n        -\u003ewhere(['Users.email' =\u003e $user_profile_info['email']])\n        -\u003efirst();\n\n      if ($user) {\n        $this-\u003eAuthentication-\u003esetIdentity($user);\n        $target = $this-\u003eAuthentication-\u003egetLoginRedirect() ?? '/';\n        return $this-\u003eredirect($target);\n      }\n\n      $this-\u003eFlash-\u003eerror('Invalid google login');\n    } catch (\\Exception $e) {\n      throw new NotFoundException($e-\u003egetMessage());\n    }\n  }\n\n  return $this-\u003eredirect(['action' =\u003e 'login']);\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farodu%2Futilcake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farodu%2Futilcake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farodu%2Futilcake/lists"}