Git Product home page Git Product logo

phpjar's Introduction

phpjar

A self-contained PHP runtime bundled in a .jar file

Build status Build status

License

phpjar includes PHP which was compiled by XAMPP. Their compilation is distributed under the terms of the GNU General Public license. Their license is described as follows:

XAMPP is a compilation of free software (comparable to a Linux distribution), it's free of charge and it's free to copy under the terms of the GNU General Public Licence. But it is only the compilation of XAMPP that is published under GPL. Please check every single licence of the contained products to get an overview of what is, and what isn't, allowed. In the case of commercial use please take a look at the product licences (especially MySQL), from the XAMPP point of view commercial use is also free.

See the XAMPP about page for more information.

Synopsis

This project aims to make it easier to set up self-contained PHP development environments. It includes the PHP distributions for Mac, Windows, and Linux - which were all extracted from XAMPP. It provides simple Java and CLI wrappers around the PHP built-in web server allowing you to fire up a server with a specified document root and port number.

Requirements

  • Java 8
  • Mac, Windows, or Linux

Current Version

The current bundled version of PHP is from XAMPP 7.2.6

Installation

If want to include phpjar in a Maven, Gradle, or SBT project see the maven installation instructions.

Download either phpjar-thin.jar or phpjar-fat.jar and add it to your project's classpath. The thin jar is only 25kb and does not include the full PHP distribution. It will download the required files from Github at runtime. The Fat jar is over 50 megabytes and includes PHP distributions for Mac, Windows, and Linux. The appropriate PHP distribution will be installed in the user's home directory on first run at $HOME/.phpjar, but this can be changed at runtime to any directory.

Usage Instructions

Starting the Server

PHPDevServer server = new PHPDevServer();
server.setDocumentRoot(new File("/path/to/htdocs"));
server.setPort(8080);	// Optional: omit to just start on available port
server.start();
	
// Server is now ready to receive requests
	

Stopping the Server

server.close();

Making HTTP Requests

HttpURLConnection conn = (HttpURLConnection)new URL("http://localhost:"+server.getPort()+"/index.php")
	.openConnection();

String contents = readFromInputStream(conn.openInputStream());

Executing PHP Directly

String hello = server.executeUTF8("<?php echo 'hello world';");
	// returns hello world

// If the PHP script outputs binary like an image, you can use
// InputStream blob = server.execute("<?php phpFuncThatOutputsBinary();");

Credits

phpjar's People

Contributors

shannah avatar

Stargazers

Mashy avatar  avatar Arun (Arundale Ramanathan) avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

phpjar's Issues

Used PHP version is insecure

Hello Friend,
Thanks a lot for the jar file, its useful, but please advise, how can we upgrade the php version used in thin client, since the current version 7.2.5 is in secure version and we need to upgrade it to version above 7.3.11 or above.
I am using thin jar.
please advise

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.