Download the PHP package samj/doctrine-sluggable-bundle without Composer

On this page you can find all versions of the php package samj/doctrine-sluggable-bundle. 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 doctrine-sluggable-bundle

DoctrineSluggableBundle

The DoctrineSluggableBundle provides a neat implementation for Doctrine2 sluggable behaviour for your entities.

The DoctrineSluggableBundle takes care of ensuring your slugs generated for your entity are unique. Simply have your entity implement the SluggableInterface interface your entities will automatically have slugs generated.

This uses the service container and dependency injection which allows you to easily create your own "Slugger" class. This supports you creating custom slugs to suit your domain problem.

This documentation is still under construction. However, an example is provided for any interested parties to begin experimenting with the package.

Contributors

Installation

Simply run assuming you have installed composer.phar or composer binary :

$ php composer.phar require samj/doctrine-sluggable-bundle 2.0

Then add this in app/AppKernel.php :

new SamJ\DoctrineSluggableBundle\SamJDoctrineSluggableBundle(),

Example Entities

Example 1

In this example, the slug is built based on a single field: Note: Make sure you implement the accessor methods getId and getTitle

Code

<?php

// --- YOUR NAMESPACE HERE ---
namespace SamJ\ExampleBundle\Entity;

use SamJ\DoctrineSluggableBundle\SluggableInterface;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table
 */
class SingleFieldExample implements SluggableInterface {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\Column(type="string")
     */
    protected $title;

    /**
     * @ORM\Column(type="string")
     */
    protected $slug;

    // Implement methods for $id, $title, etc

    public function getSlug()
    {
        return $this->slug;
    }

    public function setSlug($slug)
    {
        if (!empty($this->slug)) return false;
        $this->slug = $slug;
    }

    public function getSlugFields() {
        return $this->getTitle();
    }
}

Outcome

When the entity is persisted, the $slug field will be populated to be a 0-9, a-z only, with spaces converted to hyphens ("-"), based upon the title field.

i.e.: an entity with a title of Test Post will have a slug of test-post.

Example 2

In this example, the slug is built based on multiple single fields: Note: Make sure you implement the accessor methods getId, getTitle and getAuthor

Code

<?php

// --- YOUR NAMESPACE HERE ---
namespace SamJ\ExampleBundle\Entity;

use SamJ\DoctrineSluggableBundle\SluggableInterface;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table
 */
class MultipleSingleFieldExample implements SluggableInterface {
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     */
    protected $id;

    /**
     * @ORM\Column(type="string")
     */
    protected $title;

    /**
     * @ORM\Column(type="string")
     */
    protected $author;

    /**
     * @ORM\Column(type="string")
     */
    protected $slug;

    // Implement methods for $id, $title, $author, etc

    public function getSlug()
    {
        return $this->slug;
    }

    public function setSlug($slug)
    {
        if (!empty($this->slug)) return false;
        $this->slug = $slug;
    }

    public function getSlugFields() {
        return array($this->getAuthor(), $this->getTitle());
    }
}

Outcome

When the entity is persisted, the $slug field will be populated to be a 0-9, a-z only, with spaces converted to hyphens ("-"), based upon the author and title field.

i.e.: an entity with a author of Sam Jarrett and a title of Test Post will have a slug of sam-jarrett-test-post.

Further Notes

This bundle uses a service called the "Slugger". You can implement your own slugger behaviour (such as dealing with specific field ordering etc) by implementing the SluggerInterface->getSlug($fields) method. Configure your service container to specific the class in the parameter "sluggable.slugger.class" in your service.xml.


All versions of doctrine-sluggable-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.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 samj/doctrine-sluggable-bundle contains the following files

Loading the files please wait ....