Open drew-wallace opened 9 years ago
I have it working now. I'll make a pull request today. I have to figure out how to do it first...
Hey @drew-wallace can you explain how you solve the problem?
In my code I doesn't send the data directly from the form, I send it from a service with $http.post(); But it seems that no data arrives in the php file.
@nevyen It's been almost a year since I've looked at this. If you checkout my repo, you will find that I made it work. For the life of me I can't remember what I changed :stuck_out_tongue:
@drew-wallace I have looked at your repo and looked into the server.js. You use the same lines I do:
// must specify options hash even if no options provided!
var phpExpress = require('php-express')({
// assumes php is in your PATH
binPath: 'php'
});
// set view engine to php-express
app.set('views', config.root);
app.engine('php', phpExpress.engine);
app.set('view engine', 'php');
// routing all .php file to php-express
app.all(/.+\.php$/, phpExpress.router);
Can you help me to figure this out? Maybe you have an idea what to look for or where?
I looked at your repo and look into the php-express folder. You have changes in page_runner.php and in engine.js.
Changes: engine.js page_runner.php
It looks like the dev is actively working on this. I would ask him if what's up.
That would be nice thanks ;)
Hey @drew-wallace do you have any information for me? For now the project is getting bigger and it's a little annoying to upload the app each time.
Unfortunately no news. What exactly are you trying to do? If you are really trying to run a PHP server using node, I don't advise it. This was something I was just messing around with to see if it was possible. The problem with this method is that it executes the PHP on the command line and that means that any javascript will not execute.
Okay what I am trying to do is: We are developing an angular app but the server side is written in php. In my local devenviornment I use express with grunt to watch file changes and so on. So I need a possibility to test my requests against the php files. All get-request are no problem. But angular seems to put post-data into php://input and this isn't read by php-express.
I know it is possible to use a local apache to serve the php files but I don't want to compile the whole angular app if I change a few lines of code.
Does this explanation helps to understand what I am trying to do? If there are any questions feel free to ask.
Thanks for your support
If your app is small, it might be wise to convert your PHP into node. If that's not possible, I can take a look at this repo this weekend and see if I can figure out what's going on. If you could create an example form like the one I have at the top of this issue, then I will have something to test against.
Hey I am very sorry but yesterday I had no computer to my hand.
I found this example and add the $http function.
<!DOCTYPE html>
<html ng-app>
<head>
<title>Hello World, AngularJS - ViralPatel.net</title>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body>
<div ng-controller="ContactController">
Email:<input type="text" ng-model="new contact"/
<button ng-click="add()">Add</button>
<h2>Contacts</h2>
<ul>
<li > {{ contact }} </li>
</ul>
</div>
<script type="text/javascript">
function ContactController($scope, $http) {
$scope.add = function() {
var data = {
mail: $scope.newcontact
};
$http.post(urlToPhPScript, data).then(response => {
return response.data;
});
}
}
</script>
</body>
</html>
My Php Script looks something like this:
$bestellung = json_decode(file_get_contents("php://input"));
//$bestellung = json_decode('{"rechnung":"24h-2","mail":"testfrau@musterfrau.de"}');
$db = getConnection();
header('Content-type: application/json');
header('Cache-Control: no-cache, must-revalidate');
saveToDb($bestellung->{'mail'})
The server is given to us for low so we have no root access and we can't and won't run a node server. So we have to use php under apache.
I hope this example is enough to work with it.
Thanks again for your help.
I tried making a simple form that prints the $_POST array on submission:
It never sends off the data. Any ideas?