Download the PHP package perfectneeds/seo-multi-lang-bundle without Composer
On this page you can find all versions of the php package perfectneeds/seo-multi-lang-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download perfectneeds/seo-multi-lang-bundle
More information about perfectneeds/seo-multi-lang-bundle
Files in perfectneeds/seo-multi-lang-bundle
Package seo-multi-lang-bundle
Short Description Seo Bundle for Multi languages websites
License MIT
Homepage http://perfectneeds.github.com
Informations about the package seo-multi-lang-bundle
Getting Started With PNSeoBundle for multi languages web apps
Prerequisites
- Symfony 3.4
- PNLocaleBundle
- PNServiceBundle
Translations
If you wish to use default texts provided in this bundle, you have to make sure you have translator enabled in your config.
Installation
Installation is a quick (I promise!) 7 step process:
- Download PNSeoBundle using composer
- Enable the Bundle in AppKernel
- Create your Seo class
- Create your SeoRepository class
- Configure the PNSeoBundle
- Import PNSeoBundle routing
-
Update your database schema
Step 1: Download PNSeoBundle using composer
Require the bundle with composer:
Step 2: Enable the Bundle in AppKernel
Require the bundle with composer:
Step 3: Create your Seo class
The goal of this bundle is to persist some Seo
class to a database. Your first job, then, is to create the
Seo
class for your application. This class can look and act however
you want: add any properties or methods you find useful. This is your
Seo
class.
The bundle provides base classes which are already mapped for most fields to make it easier to create your entity. Here is how you use it:
- Extend the base
Seo
class (from theEntity
folder if you are using any of the doctrine variants) - Map the
id
field. It must be protected as it is inherited from the parent class.
Caution!
When you extend from the mapped superclass provided by the bundle, don't redefine the mapping for the other fields as it is provided by the bundle.
In the following sections, you'll see examples of how your Seo
class should look, depending on how you're storing your seos (Doctrine ORM).
Note
The doc uses a bundle named SeoBundle
. However, you can of course place your seo class in the bundle you want.
Caution!
If you override the construct() method in your Seo class, be sure to call parent::construct(), as the base Seo class depends on this to initialize some fields.
Doctrine ORM Seo class
If you're persisting your seo via the Doctrine ORM, then your Seo
class should live in the Entity namespace of your bundle and look like this to start:
*You can add all relations between other entities in this class
Step 4: Create your SeoRepository class
You can use this Repository
to add any custom methods
Step 5: Configure the PNSeoBundle
Add the following configuration to your config.yml file according to which type of datastore you are using.
Step 6: Import PNSeoBundle routing files
Step 7: Update your database schema
Now that the bundle is configured, the last thing you need to do is update your database schema because you have added a new entity, the Seo
class which you created in Step 3.
How to use PNSeoBundle
- Use Seo in Entity using Doctrine ORM
- Use Seo in Form Type
- Use Seo in controller
-
Use Seo in details page like
show.html.twig
1. Use Seo in Entity using Doctrine ORM
First of all you need to add a relation between an Entity need to use Seo with Seo class in src/PN/Bundle/SeoBundle/Entity/Seo.php
ex. Blogger, Product, etc ...
Example entities:
Seo.php
DynamicPage.php
2. Use Seo in Form Type
You need to add Seo Type in any Form type to use this magical tool
DynamicPageType.php
3. Use Seo in controller
You need to call this method to get an Entity based on slug, this method use in any action you will call an Entity through the slug
DynamicPageController.php
Options:
request:
type: Symfony\Component\HttpFoundation\Request
object
Instance of Request
slug:
type: string
The slug value that passed from route parameter
entityClass:
type: Object
An istance of any Entity
slueRouteParamName (optional, default 'slug'):
type: string
Name of slug in route annotation
4. Use Seo in details page like show.html.twig
this snippet of code used to add the meta tags and html title in base.html.twig
So you need to add 2 an empty blocks in base.html.twig
(metaTag and title)
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.
All versions of seo-multi-lang-bundle with dependencies
symfony/framework-bundle Version ~4.0|~5.0|~6.0
perfectneeds/locale-bundle Version ~2.0
perfectneeds/service-bundle Version ~2.0
ext-xmlwriter Version *