Download the PHP package niirrty/niirrty.holiday without Composer

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

Niirrty.Holiday

A extendable international holiday library.

Dieses Dokument in Deutscher Sprache anzeigen

Its realy easy to define holidays for other countries than initially supported. For mor information see Define country depending on holidays

Installation

This is a package available via composer:

or inside the require area of the composer.json:

Usage

The returned collection inside $holidays contain all holidays of defined country germany (de) with english language names (en) for used year 2018

Each collection item is a Object of type \Niirrty\Holiday\Holiday

CountryDefinitionsFactory::Create(…) also supports a 2nd parameter. With it you can define a folder that replaces the default, library depending folder with your own, to get holiday definition data from.

The HolidayCollection instance returned by ->getHolidays( … ) above also give you the methods:

Supported Countries

Currently supported countries are:

You can also get the supported countries programmatically:

Available Regions

Not all countries require the use of region depending holidays, but if required you can get the available regions by calling:

All build in countries should (not must) support name translations for languages 'de', 'en', 'fr', 'it', 'es', 'pt', 'cz' and 'jp'

If the country uses other languages it can also been defined.

Define country depending holidays

Each country define all usable holidays by using the \Niirrty\Holiday\Definition and \Niirrty\Holiday\DefinitionCollection classes, inside a separate PHP file in folder data

File naming convention

The file name must start with the 2 char ISO country ID (lower case) of the country where the holidays are for.

The file must use the PHP file name extension .php must contains valid PHP code and must return the new \Niirrty\Holiday\DefinitionCollection instance that define all country depending holiday definitions.

File structure

The base structure looks like:

Now you must get some information about the holidays (wikipedia is a good start point)

Required holiday information

Now if you have all holiday information the holidays can be defined by replacing the TODO 2 comment

Holiday definition

The simplest holiday is a holiday with a static date

The Identifier must be always unique. If the holiday is often used by many countries it is maybe defined by a constant inside Niirrty\Holiday\Identifiers

setName( '…' ) sets the country main language depending holiday name

Conditional holiday movements

But this holiday (and other in UK and many other countries) is only valid at march 17. if its not a saturday or sunday In both cases the holiday is moved to next monday.

This can be solved by extending the definition with MoveConditions

MoveCondition can also initiated with a own callback that checks if the condition matches

The conditions before does the same

Region depending holidays

If a holiday is only valid for one or more specific regions it can be declared by setValidRegions( [ … ] )

Holidays with dynamic dates

You have to define a callback that calculate the dynamic holiday depending to a year and return it. Its done by calling setDynamicDateCallback( … )

Here you have to pass a implementation of Niirrty\Holiday\Callbacks\IDynamicDateCallback

Other currently known callbacks are:

But its really simple to implement your own:

Special case - Easter depending holidays

Easter depending holidays (dynamic base date) can be easy created by using CreateEasterDepening( … )

Holiday valid for a year range

You can use setValidFromYear( … ) to set a year where the holiday starts to be valid. If not defined the lowest usable date is the default value.

You can use setValidToYear( … ) to set a year where the holiday ends to be valid. If not defined there is no limit.

If ValidToYear is before ValidFromYear it means the holiday ends to be valid at ValidToYear and newly becomes the valid state at year ValidFromYear

If there are more ranges you must define the holiday multiple times but ATTENTION: NEVER USE THE SAME IDENTIFIER!

Rest day holidays

Holidays are initially all "rest day" (work-free) holidays. If a "no rest day" Holiday should be defined you can do it by add ->setIsRestDay( false ) to the definition declaration.

The End…


All versions of niirrty.holiday with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
niirrty/niirrty.io Version ^0.6
niirrty/niirrty.date Version ^0.6
psr/log Version ^1.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 niirrty/niirrty.holiday contains the following files

Loading the files please wait ....