<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anton Dachauer</title>
    <description>The latest articles on DEV Community by Anton Dachauer (@antondachauer).</description>
    <link>https://dev.to/antondachauer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F522802%2F45045dca-7bcd-43de-af25-d798247ac632.jpg</url>
      <title>DEV Community: Anton Dachauer</title>
      <link>https://dev.to/antondachauer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/antondachauer"/>
    <language>en</language>
    <item>
      <title>Generate .ics Files with PHP</title>
      <dc:creator>Anton Dachauer</dc:creator>
      <pubDate>Sun, 27 Jul 2025 19:35:35 +0000</pubDate>
      <link>https://dev.to/antondachauer/generate-ics-files-in-php-with-ease-3c9d</link>
      <guid>https://dev.to/antondachauer/generate-ics-files-in-php-with-ease-3c9d</guid>
      <description>&lt;p&gt;If you’ve ever had to create &lt;code&gt;.ics&lt;/code&gt; files in PHP, you probably know how tedious and error-prone it can be to handle the iCalendar format manually. That’s where &lt;a href="https://git.var-lab.com/opencal/ical" rel="noopener noreferrer"&gt;&lt;code&gt;opencal/ical&lt;/code&gt;&lt;/a&gt; comes in — a clean, modern PHP library that abstracts away the complexity of generating RFC 5545-compliant iCalendar files.&lt;/p&gt;

&lt;p&gt;This package is a maintained fork of &lt;a href="https://github.com/markuspoerschke/iCal" rel="noopener noreferrer"&gt;&lt;code&gt;markuspoerschke/iCal&lt;/code&gt;&lt;/a&gt; and continues development with support for the latest PHP versions (8.1–8.4). It's already used as part of the &lt;a href="https://github.com/var-lab-it/opencal" rel="noopener noreferrer"&gt;OpenCal&lt;/a&gt; scheduling system but is fully standalone and easy to integrate into any project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use this?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✨ Clean, object-oriented API&lt;/li&gt;
&lt;li&gt;🧱 Strong separation between domain logic and rendering&lt;/li&gt;
&lt;li&gt;🧪 Fully tested and actively maintained&lt;/li&gt;
&lt;li&gt;📦 Composer installable&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require opencal/ical
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic usage
&lt;/h2&gt;

&lt;p&gt;Here’s a minimal example that creates a single-day calendar event and writes it to a &lt;code&gt;.ics&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="k"&gt;require_once&lt;/span&gt; &lt;span class="k"&gt;__DIR__&lt;/span&gt; &lt;span class="mf"&gt;.&lt;/span&gt; &lt;span class="s1"&gt;'/vendor/autoload.php'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;OpenCal\iCal\Domain\Entity\Event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;OpenCal\iCal\Domain\Entity\Calendar&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;OpenCal\iCal\Domain\ValueObject\SingleDay&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;OpenCal\iCal\Domain\ValueObject\Date&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;OpenCal\iCal\Presentation\Factory\CalendarFactory&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Create the event&lt;/span&gt;
&lt;span class="nv"&gt;$event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setSummary&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Christmas Eve'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setDescription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Family dinner and gift exchange'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;setOccurrence&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SingleDay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DateTimeImmutable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'2030-12-24'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Create the calendar&lt;/span&gt;
&lt;span class="nv"&gt;$calendar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Calendar&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nv"&gt;$event&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="c1"&gt;// Generate the iCalendar component&lt;/span&gt;
&lt;span class="nv"&gt;$calendarComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CalendarFactory&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;createCalendar&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$calendar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Save it to a file&lt;/span&gt;
&lt;span class="nb"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'christmas.ics'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$calendarComponent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Or serve it via HTTP&lt;/span&gt;
&lt;span class="cm"&gt;/*
header('Content-Type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename="christmas.ics"');
echo $calendarComponent;
*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate a valid &lt;code&gt;.ics&lt;/code&gt; file that you can import into any calendar app — Google Calendar, Apple Calendar, Outlook, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project structure
&lt;/h2&gt;

&lt;p&gt;The package is split into two main namespaces:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;OpenCal\iCal\Domain\*&lt;/code&gt;: Domain models like &lt;code&gt;Event&lt;/code&gt;, &lt;code&gt;Calendar&lt;/code&gt;, &lt;code&gt;Date&lt;/code&gt;, &lt;code&gt;TimeSpan&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OpenCal\iCal\Presentation\*&lt;/code&gt;: Responsible for converting the domain models into &lt;code&gt;.ics&lt;/code&gt; strings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it easy to test and extend the logic separately from the output format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking ahead
&lt;/h2&gt;

&lt;p&gt;We're actively maintaining the project on our &lt;a href="https://git.var-lab.com/opencal/ical" rel="noopener noreferrer"&gt;GitLab instance&lt;/a&gt;, including adding more test coverage and documentation. Feel free to open issues or contribute — no corporate hoops, just a free account needed to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;If you’re working with event data in PHP and need to export it to &lt;code&gt;.ics&lt;/code&gt; files, &lt;code&gt;opencal/ical&lt;/code&gt; will save you a ton of time. It’s small, focused, and does one thing well: generating calendar files that just work.&lt;/p&gt;

&lt;p&gt;Check it out and let us know what you think. PRs and feedback always welcome!&lt;/p&gt;

</description>
      <category>php</category>
      <category>ical</category>
      <category>ics</category>
      <category>icalendar</category>
    </item>
    <item>
      <title>What is the best way to create PDF files with PHP</title>
      <dc:creator>Anton Dachauer</dc:creator>
      <pubDate>Mon, 07 Dec 2020 14:57:33 +0000</pubDate>
      <link>https://dev.to/antondachauer/what-is-the-best-way-to-create-pdf-files-with-php-2498</link>
      <guid>https://dev.to/antondachauer/what-is-the-best-way-to-create-pdf-files-with-php-2498</guid>
      <description>&lt;p&gt;Hello, what is the best and easiest way to create PDF files with PHP?&lt;/p&gt;

&lt;p&gt;I know about libs like fpdf, tcpdf and wkhtmltopdf. But they have all their own limitations.&lt;/p&gt;

&lt;p&gt;What is your preferred way to create pdf files with php, optimaly by transforming a html file? &lt;/p&gt;

</description>
      <category>php</category>
      <category>pdf</category>
    </item>
    <item>
      <title>Hello world</title>
      <dc:creator>Anton Dachauer</dc:creator>
      <pubDate>Sun, 29 Nov 2020 18:35:46 +0000</pubDate>
      <link>https://dev.to/antondachauer/hello-world-1bn2</link>
      <guid>https://dev.to/antondachauer/hello-world-1bn2</guid>
      <description>&lt;p&gt;Hi! here I am now, in this wormhole...&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
    </item>
  </channel>
</rss>
