Download the PHP package ongr/cookies-bundle without Composer

On this page you can find all versions of the php package ongr/cookies-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 cookies-bundle

CookiesBundle

Cookies bundle provides Symfony way to handle cookies defining them as services. This allows changing the values of the service and the bundle handles the actual creation and updates of cookies.

Build Status Coverage Status Latest Stable Version Scrutinizer Code Quality

Install bundle

To install this bundle add it to composer.

Then register it in AppKernel.php

That's it - the bundle is ready for work.

Working with cookies

How to define a cookie model

ONGR provides cookie model abstraction for working with cookie values in the request and response.

One can define a service:

Notice Cookie models' names of a cookie service should not contain dot symbol '.' and must be the same as cookie names that need to be modeled.

Such injected service allows accessing cookie value. If the value has been modified by your code, it will send new value back to the client browser. Manipulating cookie values with ONGR Cookies Bundle is very easy: you need to get the cookie model service and from it you can get the cookie value with getValue() method and set the value with setValue(mixed $value) method.

Default values

Possible setDefaults keys (default values if unspecified):

These values are used to initialize the cookie model if cookie does not exist in client's browser.

Model types

Currently, there are these pre-configured classes one can use:

Manually setting cookie

If a cookie with the same name, path and domain is added to the response object, it's value is not overwritten with the changed cookie model data.

Deleting cookie

To remove a cookie from the client browser, use $cookie->setClear(true). All other model values will be ignored.

Components

  1. CookieModelListener - event listener responsible for listening for kernel.request and kernel.response events;

  2. CookieInjector - service doing the heavy lifting (gets and sets cookies).

  3. Cookie Models all implementing CookieInterface via GenericCookie class. Basic cookie fields (domain, expires, etc.) are placed in CookieFieldsTrait trait. Cookie Models are responsible for loading the raw mixed data into an nice PHP object (implementation is customizable and may differ per-model) and returning cookie-izable raw data when the need arises.

How it works?

  1. Symfony receives a request. kernel.request event is fired. CookieModelListener is listening.

  2. CookieModelListener's onKernelRequest method is called, GetResponseEvent is passed to it. onKernelRequest calls CookieInjector's inject method.

  3. CookieInjector iterates through registered Cookie Models, gets raw data for each one and calls a Cookie Model's load method to load the data from the cookie.

  4. Now we have a nice cookie-based object available!

  5. We do whatever we need to do,

  6. Symfony prepares to return a response. kernel.response event is fired. Once again, CookieModelListener is listening.

  7. CookieModelListener 's onKernelResponse method is called, FilterResponseEvent is passed to it. onKernelResponse calls CookieInjector's update method.

  8. CookieInjector iterates through cookies to be sent to the client, "flattens" them, and then iterates through registered Cookie Models, calling toCookie method to get the data to be stored in the cookie. If Cookie Model's clear property is set to true, the cookie is cleared, otherwise it is saved.

  9. Our cookie is either saved and sent to the users' browser or cleared from it.

  10. Everyone is happy.

Configuration of Cookie Models

Cookie Models are described as any other Symfony service, with one significant difference: tag ongr_cookie.cookie is used to denote that the service is a Cookie Model. All services tagged with this tag are collected in a separate compiler pass and added to the ongr_cookie.injector service by appending addCookieModel call to its' definition.

Cookie models' names of a cookie service should not contain dot symbol '.' and must be the same as cookie names that need to be modeled.

License

This bundle is under the MIT license. Please, see the complete license in the bundle LICENSE file.


All versions of cookies-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
symfony/symfony Version ~2.6|~3.0
cocur/slugify Version 0.2.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 ongr/cookies-bundle contains the following files

Loading the files please wait ....