Skip to content

TerminalDZ/electron-php-mysql

Repository files navigation

Electron-PHP-MySQL

License: MIT

An easy-to-use Electron application that integrates PHP and MySQL, providing a seamless development environment for desktop applications with web technologies. This application embeds a web view that loads content from a local PHP server.

Features

  • Electron-based desktop application with embedded web view
  • Integrated PHP server running on port 5555
  • Bundled MySQL server
  • phpMyAdmin for database management
  • Windows support (contributions for macOS and Linux support are welcome)

Prerequisites

Before you begin, ensure you have met the following requirements:

Installation

To install Electron-PHP-MySQL, follow these steps:

  1. Clone the repository:

    git clone https://github.com/TerminalDZ/electron-php-mysql.git
    
  2. Navigate to the project directory:

    cd electron-php-mysql
    
  3. Install the dependencies:

    npm install
    

Usage

To run the application:

npm start

This command will:

  1. Start the MySQL server
  2. Launch the PHP development server on port 5555
  3. Start a separate PHP server for phpMyAdmin
  4. Open the Electron application window with an embedded iframe loading content from http://localhost:5555

Accessing phpMyAdmin

You can access phpMyAdmin by:

  • Clicking on "File" > "Open phpMyAdmin" in the application menu
  • Navigating to http://127.0.0.1:2053/index.php in your web browser

Default MySQL credentials:

  • Username: root
  • Password: (empty)

Configuration

Server Ports

The application uses the following default ports:

  • MYSQL_PORT (MySQL): 3306
  • PHP_PORT (main application): 5555
  • PHPMYADMIN_PORT (phpMyAdmin): 2053

You can modify these ports in the main.js file.

PHP Server

PHP server settings can be adjusted in the startPHPServer function in main.js.

MySQL Server

MySQL configuration is defined in the mySqlConfig array in main.js.

Project Structure

  • main.js: The main Electron process file
  • renderer.js: The renderer process file
  • app.html: The main application HTML file containing the iframe
  • public_html/: Directory for your PHP files (served at http://localhost:5555)
  • mysql/: Contains the MySQL server files
  • php/: Contains the PHP executable and related files
  • phpmyadmin/: Contains the phpMyAdmin files

Development

Customizing the Application

  1. Modify the PHP files in the public_html/ directory to change the application's functionality.
  2. Adjust the Electron window settings in the createWindow() function in main.js.
  3. Customize the application menu by modifying the createMenu() function in main.js.
  4. Update the app.html file if you need to modify the iframe or add additional content to the main window.

Debugging

  • Use console.log() statements in main.js for server-side logging.
  • Access the Chromium Developer Tools for the renderer process via View > Toggle Developer Tools.
  • To debug the PHP content, use appropriate PHP debugging techniques within your public_html/ files.

Building for Production

To create a distributable for Windows:

npm run package-win

This will create distributables in the release-builds/ directory.

Contributing

Contributions to Electron-PHP-MySQL are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/AmazingFeature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some AmazingFeature')
  5. Push to the branch (git push origin feature/AmazingFeature)
  6. Open a Pull Request

We especially welcome contributions to add support for macOS and Linux platforms.

Contact

If you have any questions or suggestions, please feel free to contact us:

Acknowledgments

About

Easiest way to use PHP, mysql and laravel in electron js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •