Download the PHP package ralphjsmit/laravel-seo without Composer

On this page you can find all versions of the php package ralphjsmit/laravel-seo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-seo

laravel-seo

Never worry about SEO in Laravel again!

Currently there aren't that many SEO-packages for Laravel and the available ones are quite complex to set up and very decoupled from the database. They only provided you with helpers to generate the tags, but you still had to use those helpers: nothing was generated automatically and they almost do not work out of the box.

This package generates valid and useful meta tags straight out-of-the-box, with limited initial configuration, while still providing a simple, but powerful API to work with. It can generate:

  1. Title tag (with sitewide suffix)
  2. Meta tags (author, description, image, robots, etc.)
  3. OpenGraph Tags (Facebook, LinkedIn, etc.)
  4. Twitter Tags
  5. Structured data (Article, Breadcrumbs, FAQPage, or any custom schema)
  6. Favicon
  7. Robots tag
  8. Alternates links tag

If you're familiar with Spatie's media-library package, this package works in almost the same way, but then only for SEO. I'm sure it will be very helpful for you, as it's usually best for a website to have attention for SEO right from the beginning.

Here are a few examples of what you can do:

It will render the SEO tags directly on your page:

It even allows you to dynamically retrieve SEO data from your model, without having to save it manually to the SEO model. The below code will require zero additional work from you or from your users:

Installation

Run the following command to install the package:

Publish the migration and configuration file:

Next, go to the newly published config file in config/seo.php and make sure that all the settings are correct. Those settings are all sort of default values:

Now, add the following Blade-code on every page where you want your SEO-tags to appear:

This will render a lot of sensible tags by default, already greatly improving your SEO. It will also render things like the <title> tag, so you don't have to render that manually.

To really profit from this package, you can associate an Eloquent model with a SEO-model. This will allow you to dynamically fetch SEO data from your model and this package will generate as much tags as possible for you, based on that data.

To associate an Eloquent model with a SEO-model, add the HasSEO trait to your model:

This will automatically create and associate a SEO-model for you when a Post is created. You can also manually create a SEO-model for a Post, use the ->addSEO() method for that ($post->addSEO()).

You'll be able to retrieve the SEO-model via the Eloquent seo relationship:

On the SEO model, you may update the following properties:

  1. title: this will be used for the <title> tag and all the related tags (OpenGraph, Twitter, etc.)
  2. description: this will be used for the <meta> description tag and all the related tags (OpenGraph, Twitter, etc.)
  3. author: this should be the name of the author and it will be used for the <meta> author tag and all the related tags (OpenGraph, Twitter, etc.)
  4. image: this should be the path to the image you want to use for the <meta> image tag and all the related tags (OpenGraph, Twitter, etc.). The url to the image is generated via the secure_url() function, so be sure to check that the image is publicly available and that you provide the right path.
  5. robots
    • Overwrites the default robots value, which is set in the config. (See 'seo.robots.default').
    • String like noindex,nofollow (Specifications), which is added to <meta name="robots">

However, it can be a bit cumbersome to manually update the SEO-model every time you make a change. That's why I provided the getDynamicSEOData() method, which you can use to dynamically fetch the correct data from your own model and pass it to the SEO model:

You are allowed to only override the properties you want and omit the other properties (or pass null to them). You can use the following properties:

  1. title
  2. description
  3. author (should be the author's name)
  4. image (should be the image path and be compatible with $url = public_path($path))
  5. url (by default it will be url()->current())
  6. enableTitleSuffix (should be true or false, this allows you to set a suffix in the config/seo.php file, which will be appended to every title)
  7. site_name
  8. published_time (should be a Carbon instance with the published time. By default, this will be the created_at property of your model)
  9. modified_time (should be a Carbon instance with the published time. By default, this will be the updated_at property of your model)
  10. section (should be the name of the section of your content. It is used for OpenGraph article tags and it could be something like the category of the post)
  11. tags (should be an array with tags. It is used for the OpenGraph article tags)
  12. schema (this should be a SchemaCollection instance, where you can configure the JSON-LD structured data schema tags)
  13. locale (this should be the locale of the page. By default, this is derived from app()->getLocale() and it looks like en or nl.)
  14. robots (should be a string with the content value of the robots meta tag, like nofollow,noindex). You can also use the $SEOData->markAsNoIndex() to prevent a page from being indexed.
  15. alternates (should be an array of AlternateTag). Will render <link rel="alternate" ... /> tags.

Finally, you should update your Blade file, so that it can receive your model when generating the tags:

The following order is used when generating the tags (higher overwrites the lower):

  1. Any overwrites from the SEOManager::SEODataTransformer($closure) (see below)
  2. Data from the getDynamicSEOData() method
  3. Data from the associated SEO model ($post->seo)
  4. Default data from the config/seo.php file

Passing SEOData directly from the controller

Another option is to pass a SEOData-object directly from the controller to the layout file, into the seo() function.

Generating JSON-LD structured data

This package can also generate any structured data for you (also called schema markup). Structured data is a very vast subject, so we highly recommend you to check the Google documentation dedicated to it.

Structured data can be added in two ways:

Adding your first schema

Let's add the FAQPage schema markup to our website as an example:

[!TIP] When adding a new schema, you can check the documentation here to know what keys to add.

Pre-configured Schema: Article and BreadcrumbList

To help you get started with structured data, we added 3 preconfigured schema that you can construct using fluent methods. The following types are available:

  1. Article
  2. BreadcrumbList
  3. FAQPage

Article schema markup

In order to automatically and fluently generate Article schema markup, use the ->addArticle() method:

This will construct an article schema using all data provided by the SEOData object. You can pass a closure to ->addArticle() method to customize the individual schema markup. This closure will receive an instance of ArticleSchema as its argument. You can an additional author by using the ->addAuthor() method.

You can completely customize the schema markup by using the ->markup() method on the ArticleSchema instance:

[!TIP] Check the Google documentation about Article for more information.

BreadcrumbList schema markup

You can also add BreadcrumbList schema markup by using the ->addBreadcrumbList() function on the SchemaCollection.

By default, the schema will only contain the current url from $SEOData->url.

This code will generate BreadcrumbList JSON-LD structured data with the following four pages:

  1. Homepage
  2. Category
  3. [Current page]
  4. Subarticle

[!TIP] Check the Google documentation about BreadcrumbList for more information.

FAQPage schema markup

You can also add FAQPage schema markup by using the ->addFaqPage() function on the SchemaCollection:

[!TIP] Check the Google documentation about Faq Page for more information.

[!TIP] After generating the structured data, it is always a good idea to test your website with Google's rich result validator.

Advanced usage

Sometimes you may have advanced needs that require you to apply your own logic to the SEOData class, just before it is used to generate the tags.

To accomplish this, you can use the SEODataTransformer() function on the SEOManager facade to register one or multiple closures that will be able to modify the SEOData instance at the last moment:

Make sure to return the $SEOData object in each closure.

Modifying tags before they are rendered

You can also register closures that can modify the final collection of generated tags, right before they are rendered. This is useful if you want to add custom tags to the output or if you want to modify the output of the tags.

Roadmap

I hope this package will be useful to you! If you have any ideas or suggestions on how to make it more useful, please let me know ([email protected]) or via the issues.

PRs are welcome, so feel free to fork and submit a pull request. I'll be happy to review your changes, think along and add them to the package.

General

🐞 If you spot a bug, please submit a detailed issue and I'll try to fix it as soon as possible.

🔐 If you discover a vulnerability, please review our security policy.

🙌 If you want to contribute, please submit a pull request. All PRs will be fully credited. If you're unsure whether I'd accept your idea, feel free to contact me!

🙋‍♂️ Ralph J. Smit


All versions of laravel-seo with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/contracts Version ^9.0|^10.0|^11.0
ralphjsmit/laravel-helpers Version ^1.9
spatie/laravel-package-tools Version ^1.9.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ralphjsmit/laravel-seo contains the following files

Loading the files please wait ....