{"id":15529179,"url":"https://github.com/davidyell/cakephp-seo","last_synced_at":"2025-10-12T12:30:42.513Z","repository":{"id":17510822,"uuid":"20298746","full_name":"davidyell/CakePHP-Seo","owner":"davidyell","description":"CakePHP plugin for managing SEO","archived":true,"fork":false,"pushed_at":"2023-08-18T19:45:47.000Z","size":168,"stargazers_count":9,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-20T09:40:09.826Z","etag":null,"topics":["cakephp","cakephp-plugin","cakephp3","seo"],"latest_commit_sha":null,"homepage":null,"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/davidyell.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":"2014-05-29T15:39:13.000Z","updated_at":"2024-01-03T09:04:31.000Z","dependencies_parsed_at":"2022-08-21T09:50:22.406Z","dependency_job_id":null,"html_url":"https://github.com/davidyell/CakePHP-Seo","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidyell%2FCakePHP-Seo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidyell%2FCakePHP-Seo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidyell%2FCakePHP-Seo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidyell%2FCakePHP-Seo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidyell","download_url":"https://codeload.github.com/davidyell/CakePHP-Seo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236215216,"owners_count":19113671,"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","cakephp-plugin","cakephp3","seo"],"created_at":"2024-10-02T11:16:45.203Z","updated_at":"2025-10-12T12:30:42.142Z","avatar_url":"https://github.com/davidyell.png","language":"PHP","readme":"CakePHP-Seo\n===========\n[![Build Status](https://travis-ci.org/davidyell/CakePHP-Seo.svg?branch=master)](https://travis-ci.org/davidyell/CakePHP-Seo)\n[![Coverage Status](https://coveralls.io/repos/davidyell/CakePHP-Seo/badge.svg)](https://coveralls.io/r/davidyell/CakePHP-Seo)\n\n# What is it?\nI always need to add meta tags to my pages for SEO purposes and it was getting tedious writing tools to complete this \nevery time. So I created a component which hooks the event system to catch the `beforeLayout` event to inject SEO \ndata into the view variables.\n\nI found that by containing all the functionality for SEO inside a component it makes it easier to manage.\n\n# Requirements\n* CakePHP 3.6+\n* PHP 7.2+\n\n# Installation\n[https://packagist.org/packages/davidyell/seo](https://packagist.org/packages/davidyell/seo)\n\n```bash\ncomposer require davidyell/seo\n```\n\n# Setup\nFirstly you will need to load the plugin in your `/config/bootstrap.php`.\n```php\nPlugin::load('Seo');\n```\n\nThen you will need to attach it to the controller you want it to run on. I tend to attach it to my `AppController`.\n\n```php\n// src/Controller/AppController.php initialize() method\n$this-\u003eloadComponent('Seo.Seo' =\u003e [\n\t'defaults' =\u003e [\n\t\t'title' =\u003e 'Dave is epic',\n\t\t'description' =\u003e 'This is an epic plugin for epic people',\n\t\t'keywords' =\u003e 'epic,plugin'\n\t]\n];\n```\n\nThere are a number of configuration settings you will need to change to match your setup. You can find these in the \n`$settings` class variable in the component. Primarily you will want to change the `$settings['defaults']` to set the \ndefault title, description and keywords for your website.\n\n# How it works\nThe idea is that your model will have some fields editable in the CMS for SEO. Once this data is set to the view, the \ncomponent will catch the data and inject it into your layout for you automatically.\n\nAs such your layout will need some things to exist in order for the component to correctly add the data.\n\n```php\n// For the page title\necho $this-\u003efetch('title');\n\n// For outputting the meta tags inside \u003chead\u003e\necho $this-\u003efetch('meta');\n```\n\n# Database configuration\nThis is for you to do. How you store your SEO data is outside the scope of this plugin. However I would recommend \ncreating fields either in your `Contents` table or associated to it, with `seo_title VARCHAR(255)`, \n`seo_description TEXT`, and `seo_keywords VARCHAR(255)`. \n\n# Tips and Tricks\nGot two viewVars set in your controller and you want to change it up depending on which is set?\n```php\n// ProvidersController::beforeRender()\n\nif (isset($this-\u003eviewVars['content'])) {\n    $this-\u003ecomponents()-\u003eget('Seo')-\u003esetConfig('viewVar', 'article');\n} elseif (isset($this-\u003eviewVars['provider'])) {\n    $this-\u003ecomponents()-\u003eget('Seo')-\u003esetConfig('viewVar', 'provider');\n}\n```\n\nThe viewVar access accepts a hash path, so you can use dot notation to access deeply nested data.\n\n```php\n$this-\u003eComponents-\u003eload('Seo.Seo', [\n    'viewVar' =\u003e 'catalog',\n    'fields' =\u003e [\n        'title' =\u003e 'assigned_content.content.seo_title'\n    ]\n]);\n```\n\nDon't forget that you can set the config directly on an instance of the component.\n\n```php\n// ExamplesController.php\n\n$this-\u003ecomponents()-\u003eget('Seo')-\u003esetConfig('fields.title', 'My new title');\n```\n\n# Error handler middleware\nIt is very helpful to be able to catch 404 errors and use them to manage your SEO redirecting. This allows for only urls \nwhich do not match your application to be redirecting, avoiding any overhead.\n\nThe plugin provides a basic middleware for this purpose which can be implemented into your `/src/Application.php`\n\n```\n$this-\u003eredirects = [\n    '/examples/first-example' =\u003e [\n        'target' =\u003e '/tutorials/first',\n        'code' =\u003e 301\n    ]\n];\n$queue-\u003eadd(new \\Seo\\Error\\Middleware\\ErrorHandlerMiddleware($this-\u003eredirects))\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidyell%2Fcakephp-seo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidyell%2Fcakephp-seo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidyell%2Fcakephp-seo/lists"}