{"id":26698755,"url":"https://github.com/benhall14/php-calendar","last_synced_at":"2025-04-10T00:16:20.077Z","repository":{"id":62493098,"uuid":"86926029","full_name":"benhall14/php-calendar","owner":"benhall14","description":"A simple PHP class to generate calendars. Easy to populate, the calendar shows events by passing in an array.","archived":false,"fork":false,"pushed_at":"2025-02-05T22:51:45.000Z","size":99,"stargazers_count":82,"open_issues_count":0,"forks_count":28,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T00:16:13.674Z","etag":null,"topics":["calendar","calendars","php"],"latest_commit_sha":null,"homepage":"https://conobe.co.uk/projects/php-calendar/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benhall14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-01T16:16:53.000Z","updated_at":"2025-03-25T17:31:04.000Z","dependencies_parsed_at":"2023-11-20T22:27:05.523Z","dependency_job_id":"bc3972d0-981c-4a83-a4e4-a802c3d894ca","html_url":"https://github.com/benhall14/php-calendar","commit_stats":{"total_commits":13,"total_committers":3,"mean_commits":4.333333333333333,"dds":0.3846153846153846,"last_synced_commit":"274ab6d3214cb530ebd7d158f5752a74ceb4f9e6"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benhall14%2Fphp-calendar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benhall14%2Fphp-calendar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benhall14%2Fphp-calendar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benhall14%2Fphp-calendar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benhall14","download_url":"https://codeload.github.com/benhall14/php-calendar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131315,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calendar","calendars","php"],"created_at":"2025-03-26T22:19:13.324Z","updated_at":"2025-04-10T00:16:20.039Z","avatar_url":"https://github.com/benhall14.png","language":"PHP","readme":"# PHP Calendar\nA PHP class that makes generating calendars as easy as possible.\n\nYou can use the addEvent() or addEvents() methods to mark events on the generated calendar.\n\nThis is fully compatible with *PHP 5 through to **PHP 8.1+***\n\n# Installation via Composer\nYou can now install this class via composer.\n\n\t$ composer require benhall14/php-calendar\n\t\n**Remember** to add the composer autoloader before using the class and use the correct namespace.\n\n\trequire 'vendor/autoload.php';\n\n\tuse benhall14\\phpCalendar\\Calendar as Calendar;\n\n# Usage\nPlease make sure you have added the required classes.\n\n#### Styling\nYou can apply styles in one of three ways: \n\n1) Using $calendar-\u003estylesheet() after you have initialised a calendar;\n\n```php\n\n    $calendar = new Calendar;\n    $calendar-\u003estylesheet();\n\n```\n\n2) Using the calendar.css (or calendar.min.css) from the css directory;\n\n```html\n\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"css/calendar.min.css\"\u003e\n\n```\n3) Create your own stylesheet and add it to the head of your HTML document.\n\n#### Draw a 'Month View' calendar\n\nIn its simplest form, use the following to create a calendar for current month. This will use all defaults (English, Week starting on Sunday, including stylesheet, printing to the page).\n\n```php\n\n    (new Calendar)-\u003edisplay();\n\n```\n\nOr, you can break it down with full customisability:\n\n```php\n\n    # create the calendar object\n    $calendar = new Calendar;\n    \n    # change the weekly start date to \"Monday\"\n    $calendar-\u003euseMondayStartingDate();\n    \n    # or revert to the default \"Sunday\"\n    $calendar-\u003euseSundayStartingDate();\n    \n    # (optional) - if you want to use full day names instead of initials (ie, Sunday instead of S), apply the following:\n    $calendar-\u003euseFullDayNames();\n    \n    # to revert to initials, use:\n    $calendar-\u003euseInitialDayNames();\n\n    # use the French locale, with days and month names being translated to French.\n    $calendar-\u003esetLocale('fr_FR');\n    # This uses the Carbon locales - https://carbon.nesbot.com/docs/#api-localization\n\n    # add your own table class(es)\n    $calendar-\u003eaddTableClasses('class-1 class-2 class-3');\n    # or using an array of classes.\n    $calendar-\u003eaddTableClasses(['class-1', 'class-2', 'class-3']);\n    \n    # (optional) - if you want to hide certain weekdays from the calendar, for example a calendar without weekends, you can use the following methods:\n    $calendar-\u003ehideSaturdays();\t\t# This will hide Saturdays\n    $calendar-\u003ehideSundays(); \t\t# This will hide Sundays\n    $calendar-\u003ehideMondays(); \t\t# This will hide Mondays\n    $calendar-\u003ehideTuesdays(); \t\t# This will hide Tuesdays\n    $calendar-\u003ehideWednesdays();\t# This will hide Wednesdays\n    $calendar-\u003ehideThursdays();\t\t# This will hide Thursdays\n    $calendar-\u003ehideFridays();\t\t# This will hide Fridays\n    \n    # (optional) - Translated Calendars - currently, there is only Spanish, but see \"Translations\" below for adding your own strings.\n    $calendar-\u003euseSpanish(); \n\n    # if needed, add event\n\t$calendar-\u003eaddEvent(\n\t    '2022-01-14',   # start date in either Y-m-d or Y-m-d H:i if you want to add a time.\n\t    '2022-01-14',   # end date in either Y-m-d or Y-m-d H:i if you want to add a time.\n\t    'My Birthday',  # event name text\n\t    true,           # should the date be masked - boolean default true\n\t    ['myclass', 'abc'],   # (optional) additional classes in either string or array format to be included on the event days\n\t    ['event-class', 'abc']   # (optional) additional classes in either string or array format to be included on the event summary box\n\t);\n\n    # or for multiple events\n\n\t$events = array();\n\n\t$events[] = array(\n\t\t'start' =\u003e '2022-01-14',\n\t\t'end' =\u003e '2022-01-14',\n\t\t'summary' =\u003e 'My Birthday',\n\t\t'mask' =\u003e true,\n\t\t'classes' =\u003e ['myclass', 'abc'],\n        'event_box_classes' =\u003e ['event-box-1']\n\t);\n\n\t$events[] = array(\n\t\t'start' =\u003e '2022-12-25',\n\t\t'end' =\u003e '2022-12-25',\n\t\t'summary' =\u003e 'Christmas',\n\t\t'mask' =\u003e true\n\t);\n\n\t$calendar-\u003eaddEvents($events);\n\n    # finally, to draw a calendar    \n    echo $calendar-\u003edraw(date('Y-m-d')); # draw this months calendar    \n\n    # this can be repeated as many times as needed with different dates passed, such as:    \n    echo $calendar-\u003edraw(date('Y-01-01')); # draw a calendar for January this year    \n    echo $calendar-\u003edraw(date('Y-02-01')); # draw a calendar for February this year    \n    echo $calendar-\u003edraw(date('Y-03-01')); # draw a calendar for March this year    \n    echo $calendar-\u003edraw(date('Y-04-01')); # draw a calendar for April this year    \n    echo $calendar-\u003edraw(date('Y-05-01')); # draw a calendar for May this year    \n    echo $calendar-\u003edraw(date('Y-06-01')); # draw a calendar for June this year    \n    \n    # to use the pre-made color schemes, call the -\u003estylesheet() method and then pass the color choice to the draw method, such as:    \n    echo $calendar-\u003edraw(date('Y-m-d'));            # print a (default) turquoise calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'purple');  # print a purple calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'pink');    # print a pink calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'orange');  # print a orange calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'yellow');  # print a yellow calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'green');   # print a green calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'grey');    # print a grey calendar    \n    echo $calendar-\u003edraw(date('Y-m-d'), 'blue');    # print a blue calendar  \n    \n    # you can also call -\u003edisplay(), which handles the echo'ing and adding the stylesheet.\n    echo $calendar-\u003edisplay(array(date('Y-m-d'))); # draw this months calendar    \n\n```\n#### Draw a 'Week View' calendar\n\nInstead of a 'month view' calendar, you can now render as a 'week view'. To do this, simply use -\u003euseWeekView(). Remember, when adding events to a week-view calendar, you need to include the time too (see events above).\n\n```php\n\n    $events = array();\n\n    $events[] = array(\n        'start' =\u003e '2022-01-14 14:40',\n        'end' =\u003e '2022-01-14 15:10',\n        'summary' =\u003e 'My Birthday',\n        'mask' =\u003e true,\n        'classes' =\u003e ['myclass', 'abc']\n    );\n\n    $events[] = array(\n        'start' =\u003e '2022-11-04 14:00',\n        'end' =\u003e '2022-11-04 18:30',\n        'summary' =\u003e 'Event 1',\n        'mask' =\u003e true\n    );\n    $events[] = array(\n        'start' =\u003e '2022-11-04 14:00',\n        'end' =\u003e '2022-11-04 18:30',\n        'summary' =\u003e 'Event 2',\n        'mask' =\u003e true\n    );\n\n    $calendar = new Calendar;\n\n    $calendar-\u003eaddEvents($events)-\u003esetTimeFormat('00:00', '00:00', 10)-\u003euseWeekView()-\u003edisplay(date('Y-m-d'), 'green');\n\n```\n\nYou can change the start/end times of the day, along with the time interval by using the -\u003esetTimeFormat method:\n\n```php\n\n    $calendar-\u003esetTimeFormat('00:00', '00:00', 10)-\u003euseWeekView()-\u003edisplay(date('Y-m-d'), 'green');\n    # This will print a week view calendar with 10 minute slots from midnight to midnight - ie. 00:00, 00:10, 00:20 and so on.\n\n```\n\n#### Monday Start Date\n\nYou can now change the weekly start date from a **Sunday** to a **Monday**. To activate this, simple use the **useMondayStartingDate()** method before you 'draw'.\n\n```php\n\n    $calendar = new Calendar;\n    $calendar-\u003euseMondayStartingDate();\n    $calendar-\u003edisplay(date('Y-m-d'), 'green');\n\n```\n\n#### Translated Calendars\n\nWe now use automatically from the date and the setLocale() method. If you use -\u003esetLocale('fr_FR'), then the days and month names will be French. For more information on the Carbon localization, see https://carbon.nesbot.com/docs/#api-localization\n\n# Credits\n-   [GeoSot](https://github.com/GeoSot)\n\n# Requirements\n\n**Carbon**\n\n# License\nCopyright (c) 2016-2022 Benjamin Hall, ben@conobe.co.uk \nhttps://conobe.co.uk\n\nLicensed under the MIT license\n\n# Donate?\nIf you find this project helpful or useful in any way, please consider getting me a cup of coffee - It's really appreciated :)\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/benhall14)\n","funding_links":["https://paypal.me/benhall14"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenhall14%2Fphp-calendar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenhall14%2Fphp-calendar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenhall14%2Fphp-calendar/lists"}