Skip to content

Commit 0216994

Browse files
committed
Adding support for compser
1 parent 075e82a commit 0216994

File tree

6 files changed

+109
-6
lines changed

6 files changed

+109
-6
lines changed

composer-script.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
// composer-scripts.php
4+
5+
// Define the paths for moving directories
6+
$sourceDirs = [
7+
'sre_config' => 'sre_config',
8+
'sre_reports' => 'sre_reports',
9+
"examples" => "exampels",
10+
"db" => "db"
11+
];
12+
13+
// Get the root path of the application
14+
$rootPath = dirname(__DIR__);
15+
16+
foreach ($sourceDirs as $source => $destination) {
17+
$sourcePath = $rootPath . '/vendor/webuccinoco/sre-community/' . $source;
18+
$destinationPath = $rootPath . '/' . $destination;
19+
20+
if (is_dir($sourcePath)) {
21+
// Move the directory
22+
rename($sourcePath, $destinationPath);
23+
}
24+
}
25+

composer.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "webuccinoco/sre-community",
3+
"version": "1.0.0",
4+
"authors": [
5+
{
6+
"name": "Webuccino",
7+
"homepage": "https://mysqlreports.com/",
8+
9+
}]
10+
11+
"autoload": {
12+
"psr-4": {
13+
"webuccinoco/sre-community": "SmartReportingEngine/"
14+
},"files": ["sre_config/config.php"]
15+
},
16+
"scripts": {
17+
"post-install-cmd": [
18+
"php -f composer-scripts.php",
19+
"php -f verify-setup.php"
20+
]
21+
}
22+
}

examples/example1.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
use SRE\Engine\CustomEngine;
33
use SRE\Engine\ReportOptions;
44

5-
require_once "../sre_bootstrap.php";
5+
if (file_exists(__DIR__ ."../vendor/autoload.php"))
6+
require_once(__DIR__ ."../vendor/autoload.php");
7+
else
8+
require_once __DIR__ ."../sre_bootstrap.php";
69

710
try {
811

@@ -14,9 +17,9 @@
1417
$engine = new CustomEngine($report);
1518
$report_path = $engine->create_report();
1619
if ($report_path) {
17-
// The user will be redirected to the URL of the generated report. All generated reports are stored as subdirectories under /sre_reports.
18-
header("location: ".$report_path);
19-
exit();
20+
// The user will be redirected to the URL of the generated report. All generated reports are stored as subdirectories under /sre_reports.
21+
header("location: " . $report_path);
22+
exit();
2023
}
2124
} catch (Exception $e) {
2225
echo $e->getMessage();

examples/example2.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
use SRE\Engine\CustomEngine;
33
use SRE\Engine\ReportOptions;
44

5-
require_once "../sre_bootstrap.php";
5+
if (file_exists(__DIR__ ."../vendor/autoload.php"))
6+
require_once(__DIR__ ."../vendor/autoload.php");
7+
else
8+
require_once __DIR__ ."../sre_bootstrap.php";
69

710
try {
811

examples/example3.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
use SRE\Engine\CustomEngine;
33
use SRE\Engine\ReportOptions;
44

5-
require_once "../sre_bootstrap.php";
5+
if (file_exists(__DIR__ ."../vendor/autoload.php"))
6+
require_once(__DIR__ ."../vendor/autoload.php");
7+
else
8+
require_once __DIR__ ."../sre_bootstrap.php";
69

710
try {
811

verify-setup.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
// verify-setup.php
4+
5+
// Define the paths for the required directories
6+
$requiredDirectories = [
7+
'sre_config' => 'sre_config',
8+
'sre_reports' => 'sre_reports',
9+
"examples" => "exampels",
10+
"db" => "db"
11+
];
12+
$getting_started_url = "https://mysqlreports.com/engine/documentation/index.php?post=community_install";
13+
$required_file = "sre_config/config.php";
14+
15+
// Get the root path of the application
16+
$rootPath = dirname(__DIR__);
17+
18+
$missingDirectories = [];
19+
20+
foreach ($requiredDirectories as $source => $destination) {
21+
$destinationPath = $rootPath . '/' . $destination;
22+
23+
if (!is_dir($destinationPath)) {
24+
$missingDirectories[] = $destination;
25+
}
26+
}
27+
if(!file_exists($rootPath/$required_file)){
28+
$missingDirectories[] = $required_file;
29+
}
30+
31+
if (empty($missingDirectories)) {
32+
echo "Setup verification successful. Your package is properly configured. You can visit $getting_started_url for getting started \n";
33+
34+
} else {
35+
echo "Setup verification failed. The following files or directories are missing:\n";
36+
foreach ($missingDirectories as $directory) {
37+
echo "- {$directory}\n";
38+
}
39+
echo "Please add these directories to your project manually:\n";
40+
echo "1. Locate the 'sre-community' package directory within '/vendor/webuccinoco/sre-community'.\n";
41+
echo "2. Inside the package directory, find the missing directories: 'sre_config' and 'sre_reports'.\n";
42+
echo "3. Copy each missing directory to your project's root directory.\n";
43+
echo "4. Ensure that the copied directories are at the same level as your application files.\n";
44+
echo "5. Make sure the 'config.php' file is in the 'config' directory.\n";
45+
}
46+
47+

0 commit comments

Comments
 (0)