<?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: Sajjad Hashemian</title>
    <description>The latest articles on DEV Community by Sajjad Hashemian (@sijad).</description>
    <link>https://dev.to/sijad</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1219001%2F522bf15c-ac13-4806-9458-f478ef68607a.jpeg</url>
      <title>DEV Community: Sajjad Hashemian</title>
      <link>https://dev.to/sijad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sijad"/>
    <language>en</language>
    <item>
      <title>I Built xph: Write JSX Components, Ship Native PHP</title>
      <dc:creator>Sajjad Hashemian</dc:creator>
      <pubDate>Sun, 25 Oct 2026 09:27:40 +0000</pubDate>
      <link>https://dev.to/sijad/i-built-xph-write-jsx-components-ship-native-php-3kgm</link>
      <guid>https://dev.to/sijad/i-built-xph-write-jsx-components-ship-native-php-3kgm</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I built &lt;a href="https://github.com/sijad/xph" rel="noopener noreferrer"&gt;xph&lt;/a&gt;, an open-source compiler that lets you write Astro-like components with typed props, scoped CSS, and PHP server-side logic, then compiles them into native PHP, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;Build with Node.js. Run with PHP. No Node.js runtime required in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I built xph
&lt;/h2&gt;

&lt;p&gt;I've been working with PHP for a long time, and I still appreciate its simplicity, especially when it comes to server-side rendering.&lt;/p&gt;

&lt;p&gt;But when building modern user interfaces, I kept running into things that felt unnecessarily difficult.&lt;/p&gt;

&lt;p&gt;I wanted to keep PHP as my server-side runtime while enjoying the developer experience that modern frontend frameworks provide.&lt;/p&gt;

&lt;p&gt;There were five main reasons I started working on xph.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Server-side rendering with modern tooling
&lt;/h3&gt;

&lt;p&gt;PHP already does server-side rendering really well. I didn't want to introduce a JavaScript server just to render HTML.&lt;/p&gt;

&lt;p&gt;At the same time, I wanted the component-based workflow and development experience of tools like Astro.&lt;/p&gt;

&lt;p&gt;Ideally, I could write modern components, compile them, and deploy the result to any environment that supports PHP.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Scoped CSS without the hassle
&lt;/h3&gt;

&lt;p&gt;Writing reusable components with traditional PHP templates can get cumbersome, especially when it comes to styling.&lt;/p&gt;

&lt;p&gt;You either maintain separate stylesheets, come up with naming conventions to avoid collisions, or manually manage which styles belong to which component.&lt;/p&gt;

&lt;p&gt;I wanted to write styles directly alongside my markup and have them scoped automatically.&lt;/p&gt;

&lt;p&gt;Something as simple as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Hello world!&amp;lt;/h1&amp;gt;

&amp;lt;style&amp;gt;
  h1 {
    color: olive;
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Without worrying about that &lt;code&gt;h1&lt;/code&gt; selector affecting other components.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Modern developer tooling
&lt;/h3&gt;

&lt;p&gt;I wanted the things I've gotten used to in modern frontend development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Type checking&lt;/li&gt;
&lt;li&gt;Language Server Protocol (LSP) support&lt;/li&gt;
&lt;li&gt;Autocompletion and diagnostics&lt;/li&gt;
&lt;li&gt;Component props with clear contracts&lt;/li&gt;
&lt;li&gt;Editor integration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These features make a real difference when working on larger projects.&lt;/p&gt;

&lt;p&gt;I didn't want to give them up just because my application runs on PHP.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. JSX-like syntax for PHP
&lt;/h3&gt;

&lt;p&gt;I really like JSX. Being able to compose markup using components and expressions feels natural.&lt;/p&gt;

&lt;p&gt;PHP has a long history as a templating language, but writing complex component-based interfaces with traditional PHP syntax can become verbose.&lt;/p&gt;

&lt;p&gt;There's actually an interesting &lt;a href="https://wiki.php.net/rfc/native_markup_expressions" rel="noopener noreferrer"&gt;PHP RFC for Native Markup Expressions&lt;/a&gt;, proposing JSX-inspired markup directly in PHP.&lt;/p&gt;

&lt;p&gt;I hope we eventually see something like this supported natively.&lt;/p&gt;

&lt;p&gt;Until then, I wanted a way to use a similar authoring experience while still targeting PHP.&lt;/p&gt;

&lt;p&gt;That's one of the main ideas behind xph.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Escape-by-default safety
&lt;/h3&gt;

&lt;p&gt;This was important to me.&lt;/p&gt;

&lt;p&gt;When rendering dynamic data in HTML, escaping should be the default behavior, not something developers have to remember every time.&lt;/p&gt;

&lt;p&gt;With traditional PHP, it's easy to forget an &lt;code&gt;htmlspecialchars()&lt;/code&gt; call somewhere.&lt;/p&gt;

&lt;p&gt;I wanted dynamic expressions to be HTML-escaped automatically, with an explicit way to opt out when trusted raw HTML is actually needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Safe rendering should be the default, not an afterthought.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing xph
&lt;/h2&gt;

&lt;p&gt;These requirements eventually led me to create &lt;strong&gt;xph&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's a compiler for Astro-like &lt;code&gt;.xph&lt;/code&gt; components that outputs native PHP, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;The idea is to get a modern component authoring experience while keeping PHP responsible for server-side rendering.&lt;/p&gt;

&lt;p&gt;Here's a small example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
export interface Props {
  name: string;
}

export interface Server {
  greeting: string;
}
---

&amp;lt;script is:server&amp;gt;
  return [
    'greeting' =&amp;gt; 'Hello, ' . $props['name'],
  ];
&amp;lt;/script&amp;gt;

&amp;lt;h1&amp;gt;{server.greeting}&amp;lt;/h1&amp;gt;

&amp;lt;style&amp;gt;
  h1 {
    color: olive;
  }
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get typed props, PHP server logic, expressions in your markup, and scoped CSS in a single component.&lt;/p&gt;

&lt;p&gt;xph compiles it into assets that can be served by a normal PHP application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build with Node.js, run with PHP
&lt;/h2&gt;

&lt;p&gt;Node.js is used for development and compilation, but you don't need it in production.&lt;/p&gt;

&lt;p&gt;That means you can take advantage of modern frontend tooling without changing how your PHP application is deployed.&lt;/p&gt;

&lt;p&gt;This isn't about replacing PHP with JavaScript.&lt;/p&gt;

&lt;p&gt;It's about making the experience of writing PHP-powered user interfaces more enjoyable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give it a try
&lt;/h2&gt;

&lt;p&gt;xph is open source, and I'd really appreciate feedback from other PHP and frontend developers.&lt;/p&gt;

&lt;p&gt;I'm especially curious:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Would you use JSX-like components in a PHP project?&lt;/li&gt;
&lt;li&gt;What do you miss most from modern frontend tooling when working with PHP?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/sijad/xph" rel="noopener noreferrer"&gt;https://github.com/sijad/xph&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation:&lt;/strong&gt; &lt;a href="https://xph.js.org/" rel="noopener noreferrer"&gt;https://xph.js.org/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you find the project interesting, consider giving it a ⭐ on GitHub.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>opensource</category>
      <category>astro</category>
    </item>
    <item>
      <title>Rainbow Mouse Animation Effect</title>
      <dc:creator>Sajjad Hashemian</dc:creator>
      <pubDate>Mon, 18 Mar 2024 18:37:22 +0000</pubDate>
      <link>https://dev.to/sijad/rainbow-mouse-animation-effect-5f2b</link>
      <guid>https://dev.to/sijad/rainbow-mouse-animation-effect-5f2b</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/sijad/embed/poGMwYy?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>OGL Animated Line</title>
      <dc:creator>Sajjad Hashemian</dc:creator>
      <pubDate>Sun, 26 Nov 2023 05:59:35 +0000</pubDate>
      <link>https://dev.to/sijad/ogl-animated-line-331j</link>
      <guid>https://dev.to/sijad/ogl-animated-line-331j</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/sijad/embed/poVjvGo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webgl</category>
      <category>ogl</category>
    </item>
    <item>
      <title>Random Rects</title>
      <dc:creator>Sajjad Hashemian</dc:creator>
      <pubDate>Sun, 26 Nov 2023 05:58:10 +0000</pubDate>
      <link>https://dev.to/sijad/random-rects-382c</link>
      <guid>https://dev.to/sijad/random-rects-382c</guid>
      <description>&lt;p&gt;Check out this Pen I made!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/sijad/embed/wvNPRqZ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>context2d</category>
      <category>canvas</category>
    </item>
  </channel>
</rss>
