Sebastian De Deyne: Server side rendering JavaScript from PHP

综合技术 2018-03-13

Sebastian De Deyne
has a tutorial posted to his site showing you how to use two packages to render Javascript on the server side
via PHP.

Server side rendering is a hot topic when it comes to client side applications. Unfortunately, it's not an easy thing to do, especially if you're not building things in a Node.js environment.

I published two libraries to enable server side rendering JavaScript from PHP: spatie/server-side-rendering
and spatie/laravel-server-side-rendering
for Laravel apps.

Let's review some server side rendering concepts, benefits and tradeoffs, and build a server renderer in PHP from first principles.

The tutorial starts with a look at what "server-side rendering" means in this case, how it works with the browser and some of the benefits. It then talks about the rendering process and some of the tradeoffs between it and just using Javascript on the frontend. From there the post gets to the examples of the actual rendering process. If creates a simple Vue.js application that outputs a "Hello, world!" template. It then includes the code to use the packages (that, in turn, use the V8JS package
) to render the Javascript and output the result.

您可能感兴趣的

Pass the Jsp variable to javascript as a function ... Pass the PHP variable to Javascript at a specific point I am passing a PHP variable to Javascript, but only at a specific point ...
一看就懂的JS抽象语法树 babel是现在几乎每个项目中必备的一个东西,但是其工作原理避不开对js的解析在生成的过程,babel有引擎babylon,早期fork了项目acron,了解这个之前我们先来看看这种引擎解析出来是什么东西。不光是babel还有webpack等都是通过javascript parser将代码转化成抽...
译:如何构造我的JavaScript文件? 很多人都在问我怎么写我的JavaScript——好吧,这是一个谎言,没人问我,但是如果他们这么做了,我想指出这篇文章。在使用了多年的PHP之后,在阅读了干净代码(和其他书籍)之后,我在多年中采用了我的代码风格。是的,PHP,不要敲它,它有一个伟大的社区和伟大的编码标准。当然,多年来和别人一起写...
iOS WKWebView 与 JS 交互实战技巧 最近公司需要针对 向日葵远程控制 和 花生壳动态域名解析服务客户端 做与HTML5交互的App,优点就是开发周期短,可随时更新内容。所以在这整理了一些 App 与 Web 交互的方法。 一、WKWebView 由于Xcode8发布之后,编译器开始不支持iOS 7了,这样我们...
Customise Hyper terminal with HTML, CSS and JavaSc... A lot of developers these days are spending so much time with their terminal, that it became a vital tool in the development workflow. Since I use...