Download the PHP package puntodev/bookables without Composer

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

Bookables

Latest Version on Packagist Build Status Total Downloads

A small, framework-agnostic PHP library for computing bookable availability and time slots. You describe when something is available — with a recurring weekly schedule or a single date range — and Bookables turns that into concrete time ranges and ready-to-book slots for any window of dates.

It's a pure domain library: no framework coupling, no database, no HTTP. Drop it into any PHP application (Laravel, Symfony, plain PHP, …) that needs to answer "when can this resource be booked?". It builds on nesbot/carbon for date/time math and league/period for the Period value object used to represent ranges and slots.

Requirements

Installation

Install via Composer:

Concepts

The library is organized around a simple pipeline:

Piece Responsibility
WeeklySchedule A value object describing recurring weekly availability (per-day time ranges). JSON/array serializable, with validation.
Agenda (contract) possibleRanges(from, to) → the concrete Period ranges available within a date window.
WeeklyScheduleAgenda An Agenda backed by a WeeklySchedule.
SingleDateRangeAgenda An Agenda for one fixed start/end range.
TimeSlotter (contract) makeSlotsForDates(start, end) → the bookable slots (as Periods) within a window.
AgendaSlotter Slices an Agenda's ranges into fixed-duration slots, with optional gaps before/after.
DaySlotter Produces sliding-window slots across the whole day (ignores any agenda).
HasAgenda / TimeBookable (contracts) Interfaces you implement on your own entities (e.g. a professional, room, or resource).

All ranges and slots are returned as League\Period\Period objects. Call ->toIso8601() (or any Period method) to inspect them.

Usage

1. Define a weekly schedule

A WeeklySchedule describes, for each day of the week, the time ranges during which the resource is available. Build one from an array or from JSON — both validate the input and throw an Exception if it's malformed.

The JSON form (handy for persisting a schedule in a database column):

There's also a ready-made sample schedule (Mon–Fri 08:00–12:00 & 14:00–18:00, Sat 10:00–12:00):

Schedule JSON schema

Key Type Description
daily object Map of day-of-week (Sun, Mon, Tue, Wed, Thu, Fri, Sat) to a list of { "start": "HH:MM", "end": "HH:MM" } ranges. Times must be a zero-padded time of day (HH:MM or HH:MM:SS, 00:0023:59); relative expressions like now are rejected. start must be before end.
hours_in_advance int Minimum booking notice, in hours. Metadata only — stored and exposed via hoursInAdvance(), but not enforced by the slotters (see notes below).
disable_all bool When true, the schedule yields no availability regardless of daily. Optional, defaults to false.

2. Get available ranges from an agenda

An Agenda turns availability into the concrete date ranges that fall inside a requested [from, to] window.

For one-off availability that isn't weekly (e.g. a single open window), use SingleDateRangeAgenda. It returns the intersection of its fixed range with the requested window (or no range at all if they don't overlap):

3. Turn ranges into bookable slots

A TimeSlotter slices ranges into the actual slots a user can book.

AgendaSlotter produces fixed-duration slots inside each of an agenda's ranges:

You can reserve a gap before and/or after each appointment (in minutes). The stride between slot starts becomes duration + max(timeAfter, timeBefore):

DaySlotter ignores agendas entirely and lays a sliding window of slots across the full 24 hours of each day — useful when availability is "any time" and you only care about duration and stepping. When step is smaller than duration, slots overlap.

Timezones

Agendas compute availability in the timezone of the Carbon instances you pass in. WeeklyScheduleAgenda interprets the schedule's HH:MM times in that timezone. Note that Period::toIso8601() renders in UTC (Z), so the same wall-clock schedule in different timezones produces different UTC output:

Modeling your own bookable entities

The HasAgenda and TimeBookable contracts are there for your application to implement on its own models — for example, a professional or room that exposes an agenda:

Notes & caveats

Testing

Generate an HTML coverage report:

Changelog

Please see CHANGELOG for what has changed recently.

Releasing

Releases are cut from GitHub and the changelog is kept in sync automatically:

  1. Merge the pull requests you want to ship into master. Label them so the notes group nicely (security, enhancement, bug, dependencies, documentation); grouping is configured in .github/release.yml.
  2. On GitHub, go to Releases → Draft a new release, create a vX.Y.Z tag following SemVer, and click Generate release notes.
  3. Publish the release. Packagist picks up the new tag, and the update-changelog.yml workflow writes the release notes into CHANGELOG.md and commits them back to master.

The Unreleased section in the changelog is just an anchor — release notes flow from the published GitHub release, so there is no changelog to edit by hand.

Contributing

Please see CONTRIBUTING for details. In short: keep the library framework-agnostic, write everything in English, and include tests with every change.

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 the License File for more information.


All versions of bookables with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4 <9.0
ext-json Version *
league/period Version ^5.3
nesbot/carbon Version ^3.11
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 puntodev/bookables contains the following files

Loading the files please wait ...