index.php<\/em> file to serve as the homepage.<\/p>\nLet\u2019s start with a simple example where we display the PHP information table:<\/p>\n
\r\n<?php \r\n phpinfo();\r\n<\/pre>\nUse the following Docker command to launch your site:<\/p>\n
\r\ndocker run -v $PWD:\/app\/public -p 80:80 -p 443:443 -p 443:443\/udp dunglas\/frankenphp\r\n<\/pre>\nThis command links the current directory to the \/app\/public<\/code> directory inside the Docker container and maps ports 80<\/strong> and 443<\/strong> from the container to your host machine. The additional mapping of 443\/udp<\/strong> facilitates HTTP3 support.<\/p>\nCaddy automatically handles SSL certification and loads your site via HTTPS. However, you might encounter an SSL certificate error in your browser because it does not recognize certificates for localhost.<\/p>\n<\/span><\/span> <\/figure>\nTo bypass the HTTPS error on localhost, you can enable a specific flag in Chrome by visiting chrome:\/\/flags\/#allow-insecure-localhost<\/code>. After restarting Chrome and reloading the page, the issue should be resolved.<\/p>\n<\/span><\/span> <\/figure>\nWith FrankenPHP, your localhost now operates using the server API, with responses compressed using zstd and delivered over HTTP3. It\u2019s remarkable how this setup is achievable with just a single command.<\/p>\n
Running a Framework with FrankenPHP<\/h4>\n FrankenPHP extends beyond simple PHP files; it fully supports major PHP frameworks such as Symfony, Laravel, and others. To use it, simply mount your framework directory to the \/app\/public<\/code> directory in the Docker container. For instance, to run a Laravel application, execute this command:<\/p>\n\r\ndocker run -v $PWD:\/app -p 80:80 -p 443:443 -p 443:443\/udp dunglas\/frankenphp\r\n<\/pre>\nThis simple setup allows FrankenPHP to automatically recognize and serve the Laravel application.<\/p>\n<\/span><\/span> <\/figure>\nConcluding Thoughts<\/h4>\n The integration of features like automatic SSL, HTTP3, and advanced compression technologies simplifies and accelerates the development and deployment of PHP applications. For those accustomed to nginx or Apache, adapting to the Caddyfile configuration is the biggest change. However, it proves to be simpler and more robust than traditional web server setups once mastered.<\/p>\n
I find FrankenPHP to be an excellent solution for modern PHP applications due to its speed, scalability, and ease of use. It comes highly recommended for any PHP developers eager to enhance their setup.<\/p>\n
The post Introduction to FrankenPHP<\/a> appeared first on Hongkiat<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"FrankenPHP introduces a modernized approach to PHP architecture. FrankenPHP leverages Caddy, incorporating its built-in features such as automatic SSL, native […]<\/p>\n","protected":false},"author":1,"featured_media":1323,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/posts\/1321"}],"collection":[{"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/comments?post=1321"}],"version-history":[{"count":3,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/posts\/1321\/revisions"}],"predecessor-version":[{"id":1327,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/posts\/1321\/revisions\/1327"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/media\/1323"}],"wp:attachment":[{"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/media?parent=1321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/categories?post=1321"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/suimy.me\/index.php\/wp-json\/wp\/v2\/tags?post=1321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}