Download the PHP package zssarkany/laravel-database-sticky-timezone without Composer

On this page you can find all versions of the php package zssarkany/laravel-database-sticky-timezone. 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-database-sticky-timezone

laravel-database-sticky-timezone

Latest Version on Packagist Build Status StyleCI Scrutinizer Code Quality Code Coverage Open Issues Total Downloads

Service for keeping database connection timezone synchronized to PHP default timezone.

Purpose

There are at least two different approaches for handling database fields of timestamp type in projects:

Obviously there are pros and cons for both approaches, but if there is a requirement to support LIKE matching (e.g.: 2019-06-% or %19-06%), the first approach sems to be quite challenging.

This package aims to implement the second approach.

Storage engines store these values as 32bits unsigned integers, and string representation (YYYY-MM-DD HH:MM:SS) depends on the connection-specific timezone offset. Select, update, where expressions could provide unexpected results without appropriate caution.

Under the hood Illuminate\Database\MySqlConnection gets extended and getPdo() and getReadPdo() methods get overwritten by a change detector and actuator logic. When mentioned methods are invoked, underlying PDO object gets checked for replacement and PHP default timezone offset (date('P')) gets compared to previously set offset value. In case of change is detected, 'SET time_zone = "+hh:mm"' is executed on the specific PDO instance, where +hh:mm equals to date('P').

This makes developer able to simply update PHP default time zone with date_default_timezone_set(...) and database queries executed afterwards will be affected by the new offset. Effect is limited for timestamp fields, datetime is not affected.

Requirements

See PHP and Laravel unit and integration tests

Install

Via Composer

It is not necessary to add service provider to config/app.php, but if service discovery is disabled via composer.json, ZsSarkany\LaravelDatabaseStickyTimezone\DatabaseStickyTimezoneServiceProvider::class needs to be added before Illuminate\Database\DatabaseServiceProvider::class to providers array, otherwise the the connection resolver will be bound after the database connection is resolved already.

Usage

Append sticky_timezone => true to mysql connection configuration in config/database.php to enable automatic timezone adjustment.

Example:

SQL statements executed on this connection are taking PHP default timezone into account for timestamp fields.

PHP and Laravel unit and integration tests

Package is tested with the following conditions:

PHP Laravel Stability
7.1 5.5 stable
7.1 5.6 stable
7.1 5.7 stable
7.1 5.8 stable
7.2 5.5 stable
7.2 5.6 stable
7.2 5.7 stable
7.2 5.8 stable
7.2 6.0 stable
7.2 6.2 stable
7.3 5.5 stable
7.3 5.6 stable
7.3 5.7 stable
7.3 5.8 stable
7.3 6.0 stable
7.3 6.2 stable

Supported drivers

Package currently support MySQL driver only, but it should be easy to implement support for other drivers, which are provided by Laravel.

Contributions are welcome :)

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-database-sticky-timezone with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
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 zssarkany/laravel-database-sticky-timezone contains the following files

Loading the files please wait ....