GithubHelp home page GithubHelp logo

python-php-package's Introduction

Python-PHP-Package

This is a simple Python package that allows the client to interface with the system's PHP command without having to make lower level BASH commands or creating threads. This was a work in progress. Feel free to create a pull request to add more compataibility across operating systems.

It's important to keep in mind that this package does not create a PHP server. It only interfaces with the PHP that (hopefully) exists on the system.

Usage

Example

import php.server
import php.finder

php_location = php.finder.get_php_path()
php_server = PHPServer("path/to/files", "192.168.0.1:8888", php_location)
php_server.start()
# Some other code
php_server.stop()

php.server

The php.server package provides the PHPServer object.

PHPServer(dir, server_address, install_loc="php")
# dir is the base directory where the PHP files to be rendered are located
# server_address is the address with the form addrs:port 
# install_loc is the PHP executable location. By default, this argument calls "php" on the $PATH environment variable

The important methods it provides are the following

start()       # Start the server on a new thread
stop()        # Stop the server safely. It is strongly encouraged to always stop() the server after start()'ing it, else you run the risk of the server outliving the python code that started it.
kill()        # Stop the server unsafely. Unrecommended.
is_running()  # Returns true if the server is running.

php.finder

The php.finder provides methods of searching for the PHP server executable. This is helpful if you're unsure whether the system has the PHP call in its #PATH environment variable.

It provides the following functions

get_php_path(allow_prompt=True) # Will attempt to find the PHP server executable location. If it is unable and allow_prompt is true, it will prompt the user through the console to supply it. This value is cached and a prompt won't be necessary again as long as the PHP server executable location doesn't move.
is_php_launcher(file_loc)  # Will check to see if file_loc is a true PHP server executable
save_path(file_loc)        # Overwrites the previously cached PHP server executable location

This package was created for Arachnid which has since matured and no longer needed it. Rather than delete the package, I hope that it would be of some use to someone else.

python-php-package's People

Contributors

jake-bickle avatar

Watchers

James Cloos avatar  avatar

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.