{"id":33981303,"url":"https://github.com/codebar-ag/laravel-prerender","last_synced_at":"2025-12-13T03:39:26.720Z","repository":{"id":43147581,"uuid":"295248914","full_name":"codebar-ag/laravel-prerender","owner":"codebar-ag","description":"Laravel middleware for prerendering javascript-rendered pages onthe fly for SEO with prerender.io.","archived":false,"fork":false,"pushed_at":"2025-08-19T05:15:30.000Z","size":71,"stargazers_count":45,"open_issues_count":1,"forks_count":16,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-08-19T06:19:59.235Z","etag":null,"topics":["laravel","package","php","preprender"],"latest_commit_sha":null,"homepage":"https://prerender.io","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/codebar-ag.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-09-13T22:29:35.000Z","updated_at":"2025-08-19T05:15:19.000Z","dependencies_parsed_at":"2024-01-12T01:19:44.304Z","dependency_job_id":"260c0bad-f74c-4893-a114-d2ad813cb26e","html_url":"https://github.com/codebar-ag/laravel-prerender","commit_stats":{"total_commits":25,"total_committers":7,"mean_commits":"3.5714285714285716","dds":0.6,"last_synced_commit":"971e99db54da52482cb9d7214a61d69f6505ed83"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/codebar-ag/laravel-prerender","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-prerender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-prerender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-prerender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-prerender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebar-ag","download_url":"https://codeload.github.com/codebar-ag/laravel-prerender/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebar-ag%2Flaravel-prerender/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27699642,"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","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["laravel","package","php","preprender"],"created_at":"2025-12-13T03:39:25.357Z","updated_at":"2025-12-13T03:39:26.712Z","avatar_url":"https://github.com/codebar-ag.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://banners.beyondco.de/Laravel%20Prerender.png?theme=light\u0026packageManager=composer+require\u0026packageName=codebar-ag%2Flaravel-prerender\u0026pattern=circuitBoard\u0026style=style_2\u0026description=Integrate+Prerender.io+with+Laravel\u0026md=1\u0026showWatermark=0\u0026fontSize=175px\u0026images=template\u0026widths=500\u0026heights=500\"\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/codebar-ag/laravel-prerender.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-prerender)\n[![Total Downloads](https://img.shields.io/packagist/dt/codebar-ag/laravel-prerender.svg?style=flat-square)](https://packagist.org/packages/codebar-ag/laravel-prerender)\n[![GitHub-Tests](https://github.com/codebar-ag/laravel-prerender/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/run-tests.yml)\n[![GitHub Code Style](https://github.com/codebar-ag/laravel-prerender/actions/workflows/fix-php-code-style-issues.yml/badge.svg?branch=main)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/fix-php-code-style-issues.yml)\n[![PHPStan](https://github.com/codebar-ag/laravel-prerender/actions/workflows/phpstan.yml/badge.svg)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/phpstan.yml)\n[![Dependency Review](https://github.com/codebar-ag/laravel-prerender/actions/workflows/dependency-review.yml/badge.svg)](https://github.com/codebar-ag/laravel-prerender/actions/workflows/dependency-review.yml)\n\n\nThis package was developed to give you a quick start to integrate with the\nPrerender.io service in your Laravel application.\n\n## 🙇 Credits\n\nThis package is a clone from [jeroennoten/laravel-prerender](https://github.com/jeroennoten/Laravel-Prerender)\nwith [jeroennoten](https://github.com/jeroennoten) as the original author. \n[CasperLaiTW](https://github.com/CasperLaiTW) provided Laravel 6,7 \u0026 8 \ncompatibility by an unmerged (14th September 2020) Pull-Request.\n\n## 💡 What is Prerender.io?\n\nThe Prerender.io middleware will check each request to see if it's a from a\ncrawler. If it is a request from a crawler, the middleware will send a request\nto Prerender.io for the static HTML of that page. If not, the request will\ncontinue on to your normal server routes. The crawler never knows that you are\nusing Prerender.io since the response always goes through your server.\n\n\u003e Google now recommends that you use Prerender.io in their \n\u003e [Dynamic Rendering](https://docs.prerender.io/article/9-google-support)\n\u003e documentation!\n\n## 🛠 Requirements\n\n\n| Package |     PHP     | Laravel | Prerender.io access |\n|:-------:|:-----------:|:-------:|:-------------------:|\n| v12.0.0 | ^8.2 - ^8.4 |  12.x   |          ✅          |\n| v11.0.0 | ^8.2 - ^8.3 |  11.x   |          ✅          |\n| v3.3.0  | ^8.1 - ^8.3 |  10.x   |          ✅          |\n| v3.2.0  | ^8.0 - ^8.2 |   9.x   |          ✅          |\n| v3.1.1  | ^7.3 - ^8.1 |   8.x   |          ✅          |\n\n\n## ⚙️ Installation\n\nYou can install the package via composer:\n\n```shell\ncomposer require codebar-ag/laravel-prerender\n```\n\nIf you want to make use of the Prerender.io service, add the following to your `.env` file:\n\n```dotenv\nPRERENDER_TOKEN=token\n```\n\nOr if you are using a self-hosted service, add the server address in the `.env` file.\n\n```dotenv\nPRERENDER_URL=https://prerender.services\n```\n\nThat's it. Every GET-Request from a crawler will be prerendered.\n\n## ✋ Disable the service\n\nYou can disable the service by adding the following to your `.env` file:\n\n```dotenv\nPRERENDER_ENABLE=false\n```\n\nThis may be useful for your local development environment.\n\n## ✏️ How it works\n\n1. The middleware checks to make sure we should show a prerendered page\n\t1. The middleware checks if the request is from a crawler (agent string or `_escaped_fragment_`)\n\t2. The middleware checks to make sure we aren't requesting a resource (js, css, etc...)\n\t3. (optional) The middleware checks to make sure the url is in the whitelist\n\t4. (optional) The middleware checks to make sure the url isn't in the blacklist\n2. The middleware makes a `GET` request to the [prerender service](https://github.com/prerender/prerender) (phantomjs server) for the page's prerendered HTML\n3. Return the HTML to the crawler\n\n## 🔧 Configuration file\n\nYou can publish the config file with:\n\n```shell\nphp artisan vendor:publish --provider=\"CodebarAg\\LaravelPrerender\\LaravelPrerenderServiceProvider\"\n```\n\nAfterwards you can customize the Whitelist/Blacklist on your own.\n\nThis is the contents of the published config file:\n\n```php\n\u003c?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Enable Prerender\n    |--------------------------------------------------------------------------\n    |\n    | Set this field to false to fully disable the prerender service. You\n    | would probably override this in a local configuration, to disable\n    | prerender on your local machine.\n    |\n    */\n\n    'enable' =\u003e env('PRERENDER_ENABLE', true),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Prerender URL\n    |--------------------------------------------------------------------------\n    |\n    | This is the prerender URL to the service that prerenders the pages.\n    | By default, Prerender's hosted service on prerender.io is used\n    | (https://service.prerender.io). But you can also set it to your\n    | own server address.\n    |\n    */\n\n    'prerender_url' =\u003e env('PRERENDER_URL', 'https://service.prerender.io'),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Return soft HTTP status codes\n    |--------------------------------------------------------------------------\n    |\n    | By default Prerender returns soft HTTP codes. If you would like it to\n    | return the real ones in case of Redirection (3xx) or status Not Found (404),\n    | set this parameter to false.\n    | Keep in mind that returning real HTTP codes requires appropriate meta tags\n    | to be set. For more details, see github.com/prerender/prerender#httpheaders\n    |\n    */\n\n    'prerender_soft_http_codes' =\u003e env('PRERENDER_SOFT_HTTP_STATUS_CODES', true),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Prerender Token\n    |--------------------------------------------------------------------------\n    |\n    | If you use prerender.io as service, you need to set your prerender.io\n    | token here. It will be sent via the X-Prerender-Token header. If\n    | you do not provide a token, the header will not be added.\n    |\n    */\n\n    'prerender_token' =\u003e env('PRERENDER_TOKEN'),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Prerender Whitelist\n    |--------------------------------------------------------------------------\n    |\n    | Whitelist paths or patterns. You can use asterix syntax, or regular\n    | expressions (without start and end markers). If a whitelist is supplied,\n    | only url's containing a whitelist path will be prerendered. An empty\n    | array means that all URIs will pass this filter. Note that this is the\n    | full request URI, so including starting slash and query parameter string.\n    | See github.com/JeroenNoten/Laravel-Prerender for an example.\n    |\n    */\n\n    'whitelist' =\u003e [],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Prerender Blacklist\n    |--------------------------------------------------------------------------\n    |\n    | Blacklist paths to exclude. You can use asterix syntax, or regular\n    | expressions (without start and end markers). If a blacklist is supplied,\n    | all url's will be prerendered except ones containing a blacklist path.\n    | By default, a set of asset extentions are included (this is actually only\n    | necessary when you dynamically provide assets via routes). Note that this\n    | is the full request URI, so including starting slash and query parameter\n    | string. See github.com/JeroenNoten/Laravel-Prerender for an example.\n    |\n    */\n\n    'blacklist' =\u003e [\n        '*.js',\n        '*.css',\n        '*.xml',\n        '*.less',\n        '*.png',\n        '*.jpg',\n        '*.jpeg',\n        '*.svg',\n        '*.gif',\n        '*.pdf',\n        '*.doc',\n        '*.txt',\n        '*.ico',\n        '*.rss',\n        '*.zip',\n        '*.mp3',\n        '*.rar',\n        '*.exe',\n        '*.wmv',\n        '*.doc',\n        '*.avi',\n        '*.ppt',\n        '*.mpg',\n        '*.mpeg',\n        '*.tif',\n        '*.wav',\n        '*.mov',\n        '*.psd',\n        '*.ai',\n        '*.xls',\n        '*.mp4',\n        '*.m4a',\n        '*.swf',\n        '*.dat',\n        '*.dmg',\n        '*.iso',\n        '*.flv',\n        '*.m4v',\n        '*.torrent',\n        '*.eot',\n        '*.ttf',\n        '*.otf',\n        '*.woff',\n        '*.woff2'\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Crawler User Agents\n    |--------------------------------------------------------------------------\n    |\n    | Requests from crawlers that do not support _escaped_fragment_ will\n    | nevertheless be served with prerendered pages. You can customize\n    | the list of crawlers here.\n    |\n    */\n\n    'crawler_user_agents' =\u003e [\n        'googlebot',\n        'yahoo',\n        'bingbot',\n        'yandex',\n        'baiduspider',\n        'facebookexternalhit',\n        'twitterbot',\n        'rogerbot',\n        'linkedinbot',\n        'embedly',\n        'bufferbot',\n        'quora link preview',\n        'showyoubot',\n        'outbrain',\n        'pinterest',\n        'pinterest/0.',\n        'developers.google.com/+/web/snippet',\n        'www.google.com/webmasters/tools/richsnippets',\n        'slackbot',\n        'vkShare',\n        'W3C_Validator',\n        'redditbot',\n        'Applebot',\n        'WhatsApp',\n        'flipboard',\n        'tumblr',\n        'bitlybot',\n        'SkypeUriPreview',\n        'nuzzel',\n        'Discordbot',\n        'Google Page Speed',\n        'Qwantify'\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Timeout\n    |--------------------------------------------------------------------------\n    |\n    | Specifies the Guzzle request timeout in seconds. If the request for a\n    | prerendered page takes longer than this, the request will be terminated\n    | and the page will be loaded without prerender. A value of 0 means no\n    | timeout.\n    |\n    | See: https://docs.guzzlephp.org/en/stable/request-options.html#timeout\n    |\n    */\n\n    'timeout' =\u003e env('PRERENDER_TIMEOUT', 0),\n\n    /*\n    |--------------------------------------------------------------------------\n    | Query Parameters\n    |--------------------------------------------------------------------------\n    |\n    | By default, request query parameters are not sent to prerender when\n    | requesting the prerendered page. Setting this to true will cause the full\n    | URL, including query parameters, to be sent to prerender.\n    |\n    */\n\n    'full_url' =\u003e env('PRERENDER_FULL_URL', false),\n\n];\n```\n\n### 🤍 Whitelist\n\nWhitelist paths or patterns. You can use asterix syntax.\nIf a whitelist is supplied, only url's containing a whitelist path will be prerendered.\nAn empty array means that all URIs will pass this filter.\nNote that this is the full request URI, so including starting slash and query parameter string.\n\n```php\n// prerender.php:\n'whitelist' =\u003e [\n    '/frontend/*' // only prerender pages starting with '/frontend/'\n],\n```\n\n### 🖤 Blacklist\n\nBlacklist paths to exclude. You can use asterix syntax.\nIf a blacklist is supplied, all url's will be prerendered except ones containing a blacklist path.\nBy default, a set of asset extensions are included (this is actually only necessary when you dynamically provide assets via routes).\nNote that this is the full request URI, so including starting slash and query parameter string.\n\n```php\n// prerender.php:\n'blacklist' =\u003e [\n    '/api/*' // do not prerender pages starting with '/api/'\n],\n```\n\n## 🚧 Local testing\n\n\u003e Based on the [Getting started](https://docs.prerender.io/article/15-getting-started)\n\u003e guide in the Prerender.io documentation.\n\n1. Download and run the prerender Server locally\n```shell\ngit clone https://github.com/prerender/prerender.git\ncd prerender\nnpm clean-install\nnode server.js\n```\n\nThe default port is 3000. You can start the node server on a different port\nlike this:\n\n```shell\nPORT=3333 node server.js\n```\n\n2. Set the prerender URL:\n\n```dotenv\nPRERENDER_URL=http://localhost:3000\n```\n\n3. (Optional) Open your browser and visit the following URL. Make sure to\n   change `domain.test` to your local domain:\n\n```\nhttp://localhost:3000/render?url=https://domain.test\n```\n\n4. Test your page as a crawler. Make sure to change `domain.test` to your local\n   domain:\n\n```shell\ncurl -A Googlebot https://domain.test\n```\n\n6. 🎉 That's it — you should see the prerendered html!\n\n## 📝 Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## ✏️ Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## 🧑‍💻 Security Vulnerabilities\n\nPlease review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.\n\n## 🎭 License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebar-ag%2Flaravel-prerender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebar-ag%2Flaravel-prerender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebar-ag%2Flaravel-prerender/lists"}