dotsplatform / utils
Development tools from Dots Platform
Requires
- php: ^8.5
- illuminate/support: ^11.|^12.|^13.
- ramsey/uuid: ^4.7
Requires (Dev)
- eduarguz/shift-php-cs: ^3.0
- illuminate/config: ^11.0|^12.0|^13.0
- illuminate/container: ^11.0|^12.0|^13.0
- phpstan/phpstan: ^1.2
- phpunit/phpunit: ^9.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v2.7.0
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.1
- v2.3
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.1
- dev-feature-DEV-18868-position-range
- dev-update-php
- dev-feature-DEV-16860
- dev-use-ramsey
- dev-feature-period
- dev-add-period
- dev-feature-base64-url
- dev-feature-copy-object
- dev-feature-new-dto
- dev-feature-DEV-16113
- dev-feature-DEV-16072
- dev-feature/remove-schedule
- dev-feature-DEV-15637
- dev-feature-DEV-15556
This package is auto-updated.
Last update: 2026-11-23 20:42:54 UTC
README
Development tools shared by the Dots Platform services: DTO base classes (Dots\Data), distance and polygon helpers
(Dots\Distance), version checks (Dots\Versions) and small utilities (Dots\Utils).
composer require dotsplatform/utils
The package has no auto-discovered service providers. Everything that changes a service's behaviour is opt-in.
Coordinate ranges and longitude wrapping (v2.7.0)
One implementation of the coordinate range checks for clients-api, livesite and locations. MySQL spatial functions
(ST_GeomFromText) reject a latitude outside [-90, 90] or a longitude outside [-180, 180], and map widgets sometimes
send the centre of a map panned past the antimeridian without wrapping it (for example 390.4952 for Kyiv at
30.4952).
Dots\Distance\Position
public const float MIN_LATITUDE = -90.0; public const float MAX_LATITUDE = 90.0; public const float MIN_LONGITUDE = -180.0; public const float MAX_LONGITUDE = 180.0; public static function normalizeLongitude(float $longitude): float; public static function isLatitudeInRange(float $latitude): bool; public static function isLongitudeInRange(float $longitude): bool; public function isInRange(): bool;
normalizeLongitude()returns a longitude in [-180, 180] unchanged (both edges included). A finite longitude outside it is wrapped into [-180, 180):390.4952becomes30.4952,-1411.608294becomes28.391706,540becomes-180(never180).INF/NANare returned unchanged, so the range check rejects them.isLatitudeInRange()/isLongitudeInRange(): finite and inside the range, edges included.isInRange(): both values are not null, finite and inside the ranges.
Not changed: isValid() still only checks that both values are not null, and fromArray() / fromLonLat() /
fromString() never wrap or reject anything, so stored data is never changed silently. Wrap explicitly where a
request comes in.
Validation rules
Dots\Distance\Rules\LatitudeRule and Dots\Distance\Rules\LongitudeRule implement
Illuminate\Contracts\Validation\ValidationRule: numeric (number or numeric string), finite, inside the range, edges
included. They only check the value. Combine them with required / nullable as usual:
public function rules(): array { return [ 'latitude' => ['required', new LatitudeRule()], 'longitude' => ['required', new LongitudeRule()], ]; }
To accept an unwrapped map longitude, wrap it before validation:
protected function prepareForValidation(): void { $longitude = $this->input('longitude'); if (! is_numeric($longitude)) { return; } $this->merge(['longitude' => Position::normalizeLongitude((float) $longitude)]); }
Octane DB session timeout, set once per connection
Dots\Utils\Database\OctaneDatabaseSessionServiceProvider gives every MySQL connection of a Vapor Octane web
worker a short idle timeout (SET SESSION wait_timeout=120) as the PDO init command. MySQL runs it once, when the
connection opens or reconnects.
Why
With octane-database-session-ttl: <n> (n > 0) Vapor sends two statements on every request for every connection the
request used: SET SESSION wait_timeout=28800 before the first query and SET SESSION wait_timeout=<n> after the
response (about 0.6 ms each, inside the Lambda invocation). It also disconnects every connection the request did not
query, so the next request opens a new TLS connection (about 20 ms). With octane-database-session-ttl: 0 Vapor does
none of that, and this provider keeps the short idle timeout that protects the Aurora writer from sessions left behind
by frozen or recycled Lambda containers.
Usage
Do both steps in the same change. The provider alone does nothing useful while Vapor still sends its per-request statements, and ttl 0 alone leaves web sessions with MySQL's default idle timeout (8 hours).
-
Register the provider explicitly, in
config/app.php:'providers' => ServiceProvider::defaultProviders()->merge([ // ... Dots\Utils\Database\OctaneDatabaseSessionServiceProvider::class, ])->toArray(),
or in
bootstrap/providers.phpon the Laravel 11+ skeleton. -
In
vapor.yml, for every environment that runs Octane with persistent sessions:octane-database-session-persist: true octane-database-session-ttl: 0
Optional: a different idle timeout, in seconds, in config/database.php:
'octane_idle_session_timeout' => 180,
What it does and does not touch
- It runs only in the Vapor Octane web worker (
$_ENV['SERVER_SOFTWARE'] === 'vapor', whichLaravel\Vapor\Runtime\Octane\Octane::boot()sets before it creates the application). Queue, CLI, FPM, local and test runs are not changed. - Only connections with
driver=mysql. - An init command that a connection already has is kept. Laravel builds the read and write PDOs from
array_merge($connection, $connection['read'|'write']), so anoptionskey inside aread/writesection replaces the top-leveloptions. Such a section gets the init command too, unless it already has one (for example a reader with its own, longerwait_timeout). - If a connection's top-level options already have a different init command, that connection keeps it and gets no idle timeout. Check it after the rollout (below).
Rollout check and rollback
-
After the deploy, on the writer:
SELECT t.PROCESSLIST_DB, v.VARIABLE_VALUE AS wait_timeout, COUNT(*) AS sessions FROM performance_schema.variables_by_thread v JOIN performance_schema.threads t USING (THREAD_ID) WHERE v.VARIABLE_NAME = 'wait_timeout' AND t.PROCESSLIST_DB = '<schema>' GROUP BY t.PROCESSLIST_DB, v.VARIABLE_VALUE;
Web sessions of the service show
120(queue and CLI sessions keep the server default). -
Watch the writer's
DatabaseConnectionsin CloudWatch for an hour: it should stay flat. -
Rollback: set
octane-database-session-ttlback to120and redeploy. The provider can stay registered; with a ttl above 0 Vapor sets the timeout after every request again.