Download the PHP package laulamanapps/tokenable-symfony without Composer

On this page you can find all versions of the php package laulamanapps/tokenable-symfony. 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 tokenable-symfony

laulamanapps/tokenable-symfony

Reversible, type-prefixed, non-enumerable tokens for your Doctrine entities — so you never expose ?id=42 in a URL again. A token looks like per_3f9k2: a short type prefix plus an obfuscated id.

Internally everything stays a typed integer id; at the HTTP boundary everything is an opaque, type-tagged, non-guessable token — with zero per-controller boilerplate.

The obfuscation uses Optimus (Knuth multiplicative hashing) so ids are not sequential or guessable, then base-36 encodes them for compactness.

Why

Sequential integer ids leak information (record counts, growth rate) and invite enumeration attacks. This bundle keeps ids private without you having to thread a separate "slug" column or hand-encode anything.

Requirements

Installation

Register the bundle (Symfony Flex does this automatically):

For the app:tokenable:generate helper command, also install phpseclib (dev only):

Configuration

Everything works out of the box; configuration is optional. Defaults shown:

separator lets you switch to e.g. - (giving per-3f9k2) if _ clashes with your routing or slugs. It may be more than one character. base trades token length for the alphabet used (base 16 → 0-9a-f, base 36 → 0-9a-z).

Changing separator or base changes every token string, so treat them as set-once for a given deployment — existing URLs/bookmarks encoded under the old settings won't decode.

Usage

1. Mark an entity tokenable

Generate a fresh triplet:

Paste it onto the entity:

Each entity gets its own triplet so tokens never collide across types. The prefix must be unique and must not contain the _ separator. getId() may return an int or any value object exposing getValue(): int.

Inheritance (abstract base + discriminator map)

Declare #[Tokenable] once on an abstract Doctrine base that uses inheritance. Every concrete subclass inherits the attribute and shares one prefix and one token space:

encode(new DirectDebitMandate(...)) produces an mnd_… token; decoding resolves the prefix to the abstract base and Doctrine's discriminator loads the concrete subclass. Actions may type-hint either the abstract base or a concrete subclass — a token pointing at a sibling subclass then yields a 404. Do not add a second #[Tokenable] to the subclasses: a duplicated prefix is rejected, and a distinct one would break the shared token space.

2. Generate tokens (automatic)

3. Resolve tokens (automatic)

The value resolver runs at priority 200 (before Doctrine's own EntityValueResolver). An invalid token, an unknown prefix, or a prefix that resolves to the wrong entity type all produce a 404 — unless the argument is nullable, in which case a not-found entity yields null.

Programmatic access

Inject the Tokenizer service anywhere:

Debugging a token from the CLI

app:tokenable:convert converts a single identifier when you pass one, or drops into an interactive REPL when you don't:

Commands

Command Purpose
app:tokenable:generate <prefix> Generate a fresh prime/inverse/random triplet (needs phpseclib/phpseclib)
app:tokenable:convert [token] Convert the given token/id directly, or run interactively when omitted

How it fits together

Service Role
Tokenizer Encode/decode; discovers #[Tokenable] entities via Doctrine metadata
TokenableValueResolver Controller argument → loaded entity
TokenableUrlGenerator Router decorator — encodes ids/entities in path()/generateUrl()
TokenExtension The |token Twig filter (only registered when Twig is present)
TokenCollector Web-profiler panel (only registered when the profiler is enabled)
GenerateTokenableCommand / ConvertTokenCommand The console commands above

Development

License

MIT — see LICENSE.


All versions of tokenable-symfony with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
jenssegers/optimus Version ^1.1.2
doctrine/orm Version ^3.0
symfony/config Version ^7.1 || ^8.0
symfony/console Version ^7.3 || ^8.0
symfony/dependency-injection Version ^7.1 || ^8.0
symfony/http-foundation Version ^7.1 || ^8.0
symfony/http-kernel Version ^7.1 || ^8.0
symfony/routing Version ^7.1 || ^8.0
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 laulamanapps/tokenable-symfony contains the following files

Loading the files please wait ...