Skip to content

Commit ce1af7d

Browse files
committed
* Rewritten for Electron and updated with PHP 8.4.6
1 parent f13984c commit ce1af7d

File tree

800 files changed

+6419
-17307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

800 files changed

+6419
-17307
lines changed

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
# Application Files #
33
#####################
44

5-
releases/*
6-
win/debug.log
7-
win/webcache/*
5+
dist/*
6+
node_modules/
7+
.idea/
8+
.vscode/
89

910
######################
10-
# OS generated files #
11+
# OS Generated Files #
1112
######################
1213

1314
.DS_Store

Inno Setup Script.iss

Lines changed: 0 additions & 91 deletions
This file was deleted.

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,42 @@ PHP Fiddle is a Windows desktop application that allows you to execute PHP code
99
## Questions & Answers
1010

1111
**Where is PHP Fiddle installed?**
12-
-- PHP Fiddle is by default installed in %LocalAppData%\PHP Fiddle.
12+
-- PHP Fiddle is by default installed in %LocalAppData%\Programs\php-fiddle.
1313

1414
**Can I enable more PHP extensions or edit the PHP.ini configuration?**
15-
-- Yes, make any changes to %LocalAppData%\PHP Fiddle\php\php.ini and restart the application.
15+
-- Yes, make any changes to %LocalAppData%\Programs\php-fiddle\resources\app\php\php.ini and restart the application.
1616

1717
**Can I update the PHP version?**
18-
-- Yes, you can grab a new release of PHP at the [PHP for Windows](https://windows.php.net/download/) website and replace the folder at %LocalAppData%\PHP Fiddle\php\.
18+
-- Yes, you can grab a new release of PHP at the [PHP for Windows](https://windows.php.net/download/) website and replace the folder at %LocalAppData%\Programs\php-fiddle\resources\app\php\.
1919

2020
## Credits
2121

22-
The project is based on the innovative technology ["PHP Desktop" by Czarek Tomczak](https://github.com/cztomczak/phpdesktop) that comes wrapped with [PHP for Windows](https://windows.php.net/download/) and [Chrome Emdedded Framework (CEF)](https://github.com/chromiumembedded/cef). For distributing the software there is a prefined [Inno Setup](https://jrsoftware.org/isinfo.php) script that can be used for compiling new installation packages.
22+
The project is built with Node.js using [Electron](https://www.electronjs.org/).
2323

2424
The PHP logotype is property of [The PHP Group](https://www.php.net/credits.php).
2525

26-
The javascript source code editor bundled with this software is [CodeMirror](https://codemirror.net/).
26+
The javascript source code editor bundled with this software is [CodeMirror](https://codemirror.net/).
27+
28+
# How To Build
29+
30+
```markdown
31+
## How To Build
32+
33+
Make sure you have Node.js v22+ installed and follow these steps to build PHP Fiddle from source:
34+
35+
```bash
36+
# Clone the project and navigate to the directory
37+
git clone https://github.com/timint/phpfiddle.git && cd phpfiddle
38+
39+
# Install yarn package manager
40+
npm install --g yarn
41+
42+
# Install dependencies
43+
yarn install
44+
45+
# Simulate running the app
46+
yarn run start
47+
48+
# Build and compile app to dist/ folder
49+
yarn run build
50+
```

app/config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"php": {
3+
"directory": "php",
4+
"docroot": "web",
5+
"port": 5555,
6+
"directives": {
7+
"display_errors": 0,
8+
"expose_php": 0
9+
}
10+
},
11+
"window": {
12+
"width": 1200,
13+
"height": 720
14+
}
15+
}

app/main.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { dirname, join } from 'path';
2+
import { fileURLToPath } from 'url';
3+
import { readFileSync } from 'fs';
4+
import PHPServer from './server.mjs';
5+
import electron from 'electron';
6+
7+
const _dirname = dirname(fileURLToPath(import.meta.url));
8+
const configFile = join(_dirname, 'config.json');
9+
const config = JSON.parse(readFileSync(configFile, 'utf-8'));
10+
11+
const { app, Menu, BrowserWindow } = electron;
12+
13+
const phpRuntime = new PHPServer({
14+
php: join(_dirname, config.php.directory, 'php'),
15+
directory: join(_dirname, config.php.docroot),
16+
port: config.php.port,
17+
stdio: 'ignore',
18+
directives: config.php.directives,
19+
});
20+
21+
let mainWindow;
22+
function createWindow() {
23+
let runtimePromise = phpRuntime.run();
24+
25+
mainWindow = new BrowserWindow({width: config.window.width, height: config.window.height});
26+
mainWindow.loadURL('http://'+phpRuntime.host+':'+phpRuntime.port+'/');
27+
28+
//mainWindow.webContents.openDevTools()
29+
30+
mainWindow.on('closed', function () {
31+
phpRuntime.close();
32+
mainWindow = null;
33+
})
34+
}
35+
36+
app.on('ready', () => {
37+
38+
// Set the application menu to null to remove it
39+
Menu.setApplicationMenu(null);
40+
41+
// Create the main window
42+
createWindow();
43+
});
44+
45+
app.on('window-all-closed', () => {
46+
if (process.platform !== 'darwin') {
47+
phpRuntime.close();
48+
app.quit();
49+
}
50+
});
51+
52+
app.on('activate', () => {
53+
if (mainWindow === null) {
54+
createWindow();
55+
}
56+
});

app/package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "php-fiddle",
3+
"productName": "PHP Fiddle",
4+
"version": "8.4.6",
5+
"description": "Develop desktop apps using php as backend for electron.",
6+
"repository": "https://github.com/timint/phpfiddle",
7+
"keywords": [
8+
"Electron",
9+
"desktop application",
10+
"PHP",
11+
"cross-platform"
12+
],
13+
"author": "T. Almroth",
14+
"license": "CC0-1.0",
15+
"type": "module",
16+
"main": "main.mjs",
17+
"engines": {
18+
"node": ">=22.0.0"
19+
}
20+
}

0 commit comments

Comments
 (0)