Aurelia + Php可能/推荐? [英] Aurelia + Php Possible/Recommended?

查看:67
本文介绍了Aurelia + Php可能/推荐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此问题解决之前,我知道上面的设置是可能的.我只想澄清一些事情.

Before this question gets closed, I know the setup above is possible. I just want clarification on some things.

我刚开始学习Aurelia,因为我想将我的项目之一转换为Web应用程序.我的项目是使用html + css + JavaScript(jQuery)+ PHP(MySql)构建的.

I just started learning Aurelia because I want to convert one of my projects into a web app. My project is built with html+css+JavaScript(jQuery)+ PHP(MySql).

我以前没有使用过任何框架.

I havent used any sort of framework before.

在指南中,他们提到了几种设置Web服务器的方法.我将http服务器与node一起使用.现在,在这里我需要一些帮助来理解一些事情.

In the guide, they mention a few ways to setup a web server. I used the http server with node. Now this is where I need some help understanding a few things.

我不想使用node.js.我想在服务器上使用PHP.那行得通,怎么办?

I dont want to use node.js. I want to use PHP on the server. Will that work and how?

使用Apache服务器时,我知道任何PHP页面都会发送到呈现最终html的解释器.我使用XAMPP,它的apache与PHP捆绑在一起.节点使用的http服务器是否随PHP一起提供?这甚至是一个明智的问题吗?

When using Apache server, I know any PHP page is sent to the interpreter that renders the final html. I use XAMPP and its apache comes bundled with PHP. Does the http server used by node come with PHP? Is this even a sensible question?

现在我知道Aurelia完全是前端.如果用于制作单页应用程序,则使用Ajax.所以现在我做了以下假设:

Now I know Aurelia is purely front end. If it used to make single page applications, it uses Ajax. So now I made the following assumption:

用户使用Aurelia访问Web服务器发送的应用程序的根页面.之后,Aurelia向服务器发出各种Ajax请求,这些请求将使用我的PHP文件进行数据库查询.

Using Aurelia, the user accesses the root page of the app that the web server sends. After that, Aurelia makes various Ajax requests to the server which will use my PHP files to do database query stuff.

是对的还是我错过了什么.而且我可以只使用xampp(apache)托管我的应用程序,而不是从节点托管服务器吗?

Is that right or am I missing something. And can I just use xampp(apache) to host my app instead of server from node?

推荐答案

Aurelia是一个框架,在将其导出到任何服务器后,它完全不依赖任何后端软件.这意味着借助http- / fetch-client API,您可以直接调用php脚本.

Aurelia is a framework that, after you export it to any server, does not rely on any back-end software at all. This means that with the help of the http- / fetch-client API, you can just call out to your php script.

我在github中有一个例子: https://github.com/rjpvroegop/randyvroegop.nl-made-with-aurelia

I have an example in my github: https://github.com/rjpvroegop/randyvroegop.nl-made-with-aurelia

在这里,我使用http客户端将数据发布到我的php脚本中,因为它具有非常简单的电子邮件功能.

Here I use the http-client to post data to my php script wich has a very simple email functionality.

您可以在src/pages/contact/index.jsview-model中看到操作. 您可以在src/assets/components/contactengine.php中看到PHP脚本.

You can see the action inside my view-model in src/pages/contact/index.js. You can see the PHP script in src/assets/components/contactengine.php.

这些按应有的方式工作.注意:如果要以PHPgulp-export之后的dist文件夹中的PHP作为我的服务方式,则必须更改gulp的构建.

These work the way they should. Note: you have to change your gulp build if you want your PHP served the way I serve mine, from the dist folder after gulp-watch or gulp-export.

此外,您可以使用任何想要的后端功能,只要它返回正确的数据即可.这个PHP脚本可以做到这一点.如果您要下载我的发行版以对此进行测试,则只需执行以下操作即可:

Next to that you can use any back-end functionality you would like, as long as it returns the proper data. This PHP script does that. If you would download my distribution to test this you can simply do the following:

gulp export在根文件夹中

将所有内容从导出文件夹复制到您的PHP Web服务器.

copy everything from the export folder to your PHP webserver.

这篇关于Aurelia + Php可能/推荐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆