Download the PHP package langemike/php-store-hours without Composer

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

PHP Store Hours for Laravel

PHP Store Hours is a simple PHP class that outputs content based on time-of-day and-day-of-week. Simply include the script in any PHP page, adjust opening and closing hours for each day of the week and the script will output content based on the time ranges you specify.

Easily set open hours for each day of the week

// REQUIRED
// Define daily open hours
// Must be in 24-hour format, separated by dash
// If closed for the day, leave blank (ex. sunday) or don't add line
// If open multiple times in one day, enter time ranges separated by a comma
$hours = array(
    'mon' => array('11:00-20:30'),
    'tue' => array('11:00-13:00', '18:00-20:30'),
    'wed' => array('11:00-20:30'),
    'thu' => array('11:00-1:30'), // Open late
    'fri' => array('11:00-20:30'),
    'sat' => array('11:00-20:00'),
    'sun' => array() // Closed all day
);

Add exceptions for specific dates / holidays

// OPTIONAL
// Add exceptions (great for holidays etc.)
// MUST be in format month/day[/year] or year-month-day
// Do not include the year if the exception repeats annually
$exceptions = array(
    '2/24'  => array('11:00-18:00'),
    '10/18' => array('11:00-16:00', '18:00-20:30')
);

Customize the final output with shortcodes

Choose what you'd like to output if you're currently open, currently closed, or closed all day. Shortcodes add dynamic times to your open or closed message.

// OPTIONAL
// Place HTML for output below. This is what will show in the browser.
// Use {%hours%} shortcode to add dynamic times to your open or closed message.
$template = array(
    'open'           => "<h3>Yes, we're open! Today's hours are {%hours%}.</h3>",
    'closed'         => "<h3>Sorry, we're closed. Today's hours are {%hours%}.</h3>",
    'closed_all_day' => "<h3>Sorry, we're closed today.</h3>",
    'separator'      => " - ",
    'join'           => " and ",
    'format'         => "g:ia", // options listed here: http://php.net/manual/en/function.date.php
    'hours'          => "{%open%}{%separator%}{%closed%}"
);

Available Methods

render([timestamp = time()])

This is the default method that outputs the templated content. You'll most likely want to use this.

$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->render();

hours_overview([groupSameDays = false])

This returns an array with a full list of open hours (for a week without exceptions). Days with same hours will be grouped.

$store_hours = new StoreHours($hours, $exceptions, $template);

echo '<table>';
foreach ($store_hours->hours_overview() as $days => $hours) {
    echo '<tr>';
    echo '<td>' . $days . '</td>';
    echo '<td>' . $hours . '</td>';
    echo '</tr>';
}
echo '</table>';

hours_today([timestamp = time()])

This returns an array of the current day's hours.

$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->hours_today();

is_open([timestamp = time()])

This returns true/false depending on if the store is currently open.

$store_hours = new StoreHours($hours, $exceptions, $template);
$store_hours->is_open();

Use Cases

Multiple stores / sets of hours

If you'd like to show multiple sets of hours on the same page, simply invoke two separate instances of StoreHours. Remember to set the timezone before each new instance.

// New York Hours
date_default_timezone_set('America/New_York');
$nyc_store_hours = new StoreHours($nyc_hours, $nyc_exceptions, $nyc_template);
$nyc_store_hours->render();

// Los Angeles Hours
date_default_timezone_set('America/Los_Angeles');
$la_store_hours = new StoreHours($la_hours, $la_exceptions, $la_template);
$la_store_hours->render();

Testing

$ phpunit

Troubleshooting

If you're getting errors or if times are not rendering as expected, please double check these items before filing an issue on GitHub:

Please report any bugs or issues here on GitHub. I'd love to hear your ideas for improving this script or see how you've used it in your latest project.

Sites using PHP Store Hours

Credits

Goes to Cory Etzkorn for developing php-store-hours


All versions of php-store-hours with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.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 langemike/php-store-hours contains the following files

Loading the files please wait ....