Git Product home page Git Product logo

php-express's People

Contributors

fdn avatar jacargentina avatar nobii avatar toyamarinyon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

php-express's Issues

need means of increasing maxBuffer for child-process exec

Large response sizes from php scripts trigger maxBuffer error:

Error: stdout maxBuffer exceeded.    
at Socket.<anonymous> (child_process.js:792:12)    
at Socket.emit (events.js:107:17)    
at readableAddChunk (_stream_readable.js:163:16)    
at Socket.Readable.push (_stream_readable.js:126:10)    
at Pipe.onread (net.js:538:20)

This can be resolved by inserting a maxbuffer increase in engine.js. line 39, e.g.:

child_process.exec(command,  {maxBuffer: 1024 * 15000}, function (error, stdout, stderr) 

Not sure how best to pass in such an argument when configuring php-express - would be preferable to editing source for each installation.

header() statements ignored?

I'm using php-express to serve PHP pages that occasionally return content other than text/html. In particular, I have a page which returns JSON, and has a header("Content-type: application/json") statement. However, the headers returned from this request are still text/html, as verified by the network monitor in FireFox, and the fact that prototype.js (which I'm using in the code which reads this response) does not set responseJSON in the Ajax response.

I've gotten around this problem by using prototype.js's evalJSON() function, but this fails to address the issue.

PHP_SELF is always set to page_runner.php

I have php code that depends on the value of the current location using $_SERVER['PHP_SELF'] but it looks like no matter what page I'm on that value is set to this:
[PHP_SELF] => server/node_modules/php-express/lib/PHPExpress/../../page_runner.php
Is there a way to have the $_SERVER values set to reflect the requested url?

Also the $_SERVER['REQUEST_URI'] value is not set at all (otherwise I could use that instead).

export not recognized?

I can get my server running, I even copied the basic app.js from the readme, and it still says "Error: Command failed: 'export' is not recognized as an internal or external command,
operable program or batch file".

I'm on windows.

Am I doing something wrong? Do I have to set an env variable?

child_process缓冲区溢出

child_process.exec(command,{
	env: env,
        maxBuffer: 8 * 1024 * 1024
},
...

lib/PHPExpress/engine.js 第32到34行,没有设置maxBuffer导致缓冲区大小只有默认的200k,当页面大小超出200k页面就会被截断,建议添加maxBuffer参数,如上

use with template engine

your module can be used with template engines?

app.engine('php', phpExpress.engine);
app.set('view engine', 'php');
app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views');
app.set('view engine', 'html');

how to install php binaries with npm?

Error: Command failed: php ...................... php-express/lib/PHPExpress/../../page_runner.php /home/runner/Express-Server/views .............................. /views/index.php
/bin/sh: 1: php: not found

at ChildProcess.exithandler (child_process.js:308:12)
at ChildProcess.emit (events.js:314:20)
at ChildProcess.EventEmitter.emit (domain.js:483:12)
at maybeClose (internal/child_process.js:1022:16)
at Socket.<anonymous> (internal/child_process.js:444:11)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at Pipe.<anonymous> (net.js:675:12)

shell_exec not allowed?

I have a local server and script and was working fine before, but now it hangs when I use any shell_exec function (even to just log or write something for test). Is this new? It has been working for years before.

Do I need to set anything to allow it?

php-express downloads the page instead of rendering it

basically i copy pasted you example and changed the directories, but when i request the page i get a download
php is the path

const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
const submission = require('./models/submission');
const cors = require('cors');

const app = express();

var phpExpress = require('php-express')({

    // assumes php is in your PATH
    binPath: 'php'
});

app.set('views', path.join(__dirname, 'end-user/dist'));
app.engine('php', phpExpress.engine);
app.set('view engine', 'php');

// routing all .php file to php-express
app.all(/.+\.php$/, phpExpress.router);
// Parsers for POST data
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: false, limit: '10mb' }));

// Point static path to dist
app.use(express.static(path.join(__dirname, 'end-user/dist')));

app.get('*', (req, res) => {
    console.log('HAllo?!');
    res.sendFile(path.join(__dirname, '/end-user/dist/index.php'));
});

console.log(__dirname);
/**
 * Get port from environment and store in Express.
 */
const port = process.env.PORT || '16484';
app.set('port', port);

/**
 * Create HTTP server.
 */
const server = http.createServer(app);

/**
 * Listen on provided port, on all network interfaces.
 */
server.listen(port, () => console.log(`API running on localhost:${port}`));

Form POST doesn't work

I tried making a simple form that prints the $_POST array on submission:

<html>
<head>
        <meta charset="UTF-8">
</head>
<body>
<?php
        if(isset($_POST['uname'])) {
                print_r($_POST);
        }
?>
<form action='http://example.com/current_page.php' method='post'>
Username:<br>
<input type='text' name='uname'><br>
Password:<br>
<input type='password' name='pword'><br><br>
<input type='submit' value='Submit'>
</form>

</body>
</html>

It never sends off the data. Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.