Skip to content

Commit

Permalink
Initialized repo
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardosahon committed Dec 15, 2023
1 parent b7b3189 commit b28c2c7
Show file tree
Hide file tree
Showing 98 changed files with 9,307 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/vendor/
/res/uploads/
/.lay_temp/

# Logs
.logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
*.env

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
*.cache/
*.config/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

54 changes: 54 additions & 0 deletions Autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);

namespace BrickLayer\Lay;

class AutoLoader
{
private static string $root_dir;

private function __construct()
{
}

private function __clone()
{
}

public static function get_root_dir(): string
{
if(isset(self::$root_dir))
return self::$root_dir;

$s = DIRECTORY_SEPARATOR;

self::$root_dir = explode
(
"{$s}vendor{$s}bricklayer{$s}lay",
__DIR__ . $s
)[0] . $s;

return self::$root_dir;
}

public static function load_framework_classes(): void
{
spl_autoload_register(function ($className) {
$location = str_replace('\\', DIRECTORY_SEPARATOR, $className);

@include_once self::get_root_dir() . $location . '.php';
});
}

public static function load_composer(): void
{
try{
@require_once self::get_root_dir() . "vendor" . DIRECTORY_SEPARATOR . "autoload.php";
} catch (\Error) {
echo "Composer autoload.php file does not exit. Please run <b>composer dump-autoload</b> on your project root.\n";
}
}
}

AutoLoader::load_composer();
AutoLoader::load_framework_classes();
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ![Lay A Lite Php Framework](https://github.com/leonardosahon/Lay/blob/main/init-lay-res/files/logo.png)

Lay A Lite Php Framework to get your project up and running.

PHP Version: `8.1 >`
Current Version: `1.0.0`

## Get Started

1. Ensure you have at the latest specified version of php installed.
2. Copy the `init-lay` file to your server root directory or where you wish to initialize new projects using the command line.
3. Open the script and replace the `$default_lay_location` variable with the path of the Lay package you cloned.
4. To create a new project, open your command line app and type `php init-lay sample-project` or use `php init-lay -h` for help on how to use the script.
5. When the script is done, you can open the project like a regular webserver project. Example: `localhost/sample-project`

## Documentation

We wil begin creating officials documentations soon, please bear with us for the moment.

When that is ready, it'll be available at https://lay.osaitech.dev
185 changes: 185 additions & 0 deletions bob.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#!/usr/bin/env php
<?php

use BrickLayer\Lay\core\LayConfig;
const SAFE_TO_INIT_LAY = true;
$s = DIRECTORY_SEPARATOR;

include_once __DIR__ . DIRECTORY_SEPARATOR . "Autoloader.php";

$intro = function() {
cmd_out(
"----------------------------------------------------------\n"
. "-- Name: \t Bob The Builder \n"
. "-- Author: \t Osahenrumwen Aigbogun \n"
. "-- Created: \t 14/12/2023; \n"
. "----------------------------------------------------------"
);
};

$script_name = "./bob";

function get_arg(string $arg, int|array $index, &$pipe, string ...$cmd_key) : void
{
global $argv;

if(!in_array($arg, $cmd_key, true))
return;

if(is_int($index) && $index == 0) {
$pipe = true;
return;
}

if(is_int($index)) {
$pipe = $argv[($index + 1)] ?? null;
return;
}

foreach ($index as $i) {
$pipe[] = $argv[($i + 1)] ?? null;
}
};

function cmd_out(string $message, array $opts = []) : void
{
print "##>>> BobTheBuilder SAYS (::--__--::)\n\n";

foreach (explode("\n", $message) as $m) {
print " " . $m . "\n";
}

print "\n####> BobTheBuilder DONE TALKING...(-_-)\n";
die;
};


if($argc == 1) {
$intro();
die;
}

$opts = [];
foreach ($argv as $k => $a) {
get_arg($a, $k, $opts['link_htaccess'], "link:htaccess");
get_arg($a, [$k, $k + 1], $opts['link_dir'], "link:dir");
get_arg($a, [$k, $k + 1], $opts['link_file'], "link:file");
get_arg($a, 0, $opts['force_action'], "--force");
}

if(@$opts['help']) {
$intro();
cmd_out(
">>> Bob The Builder is meant aid in building your application\n" .
">>> directory indicated using the -o flag. This helps save production time\n" .
"----------------------------------------------------------\n" .
"### Usage: [$script_name] {directory_name} [--output || -o] {output_directory}\n" .
"### Example: php $script_name dir/js -o prod-dir/js"
, ["type" => "info"]
);
}

$fs = LayConfig::server_data();
$s = DIRECTORY_SEPARATOR;
$force = $opts['force_action'] ?? false;

if($dest = @$opts['link_htaccess']) {
$dest = $fs->domains . rtrim(str_replace(".htaccess","", $dest), "/") . $s;

if(!is_dir($dest)) {
if(!$force)
cmd_out("Directory $dest does not exist! if you want the directory to be created automatically, pass the flag --force", [
"type" => "fail"
]);

umask(0);
mkdir($dest, 0777, true);
}

$dest .= ".htaccess";

if(file_exists($dest)) {
if(!$force)
cmd_out(
"htaccess exists already at: $dest"
. "If you want to REPLACE!! it, pass the flag --force\n"
. "***### Take Note:: You will be deleting the former htaccess if you decide to pass the flag --force"
, ["type" => "warn"]
);

unlink($dest);
}

symlink($fs->web . ".htaccess", $dest);

cmd_out("htaccess successfully linked to: $dest", [
"type" => "success"
]);
}

if($link = @$opts['link_dir']) {

$src = $fs->root . $link[0];
$dest = $fs->root . $link[1];

if(!is_dir($src))
cmd_out(
"Source directory $src does not exist!\n"
. "You cannot link a directory that doesn't exist"
, ["type" => "fail"]
);

if(is_dir($dest)) {
if(!$force)
cmd_out(
"Destination directory: $dest exists already!\n"
. "If you want to REPLACE!! it, pass the flag --force\n"
. "***### Take Note:: You will be deleting the former directory if you decide to pass the flag --force"
, ["type" => "warn"]
);

unlink($dest);
}

symlink($src, $dest);

cmd_out(
"Directory link created successfully!\n"
. "Source Directory: $src\n"
. "Destination Directory: $dest"
, [ "type" => "success" ]
);
}

if($link = @$opts['link_file']) {

$src = $fs->root . $link[0];
$dest = $fs->root . $link[1];

if(!file_exists($src))
cmd_out("Source file $src does not exist! You cannot link a file that doesn't exist", [
"type" => "fail"
]);

if(file_exists($dest)) {
if(!$force)
cmd_out(
"Destination file: $dest exists already!\n"
. "If you want to REPLACE!! it, pass the flag --force\n"
. "***### Take Note:: You will be deleting the former file if you decide to pass the flag --force"
,["type" => "warn"]
);

unlink($dest);
}

symlink($src, $dest);

cmd_out(
"Directory link created successfully!\n"
. "Source Directory: $src\n"
. "Destination Directory: $dest"
, [ "type" => "success" ]
);
}

62 changes: 62 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "bricklayer/lay",
"description": "A lite PHP builder meta-framework to get your projects up and running quickly",
"keywords": ["framework", "lay", "lite framework", "lite php framework", "metaframework", "fast php framework"],
"type": "library",
"license": "GPL-3.0",
"autoload": {
"psr-4": {
"BrickLayer\\Lay\\": "src/"
}
},
"authors": [
{
"name": "Osahenrumwen Aigbogun",
"email": "[email protected]"
}
],
"support": {
"source": "https://github.com/PHPBrickLayer/lay",
"issues": "https://github.com/PHPBrickLayer/lay/issues"
},
"require": {
"php": "^8.1",
"vlucas/phpdotenv": "^5.5.0",
"wolfcast/browser-detection": "^2.9.7",
"phpmailer/phpmailer": "^6.8.0",
"ext-openssl": "*",
"ext-mysqli": "*",
"ext-json": "*",
"ext-exif": "*",
"ext-gd": "*",
"ext-sodium": "*",
"ext-fileinfo": "*",
"ext-dom": "*"
},
"require-dev": {
"phpunit/phpunit": "^10.3.2"
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"minimum-stability": "stable",
"prefer-stable": true,
"extra": {
"npm-packages": {
"terser": "5.15.1",
"clean-css": "3.4.12"
}
}
}
Loading

0 comments on commit b28c2c7

Please sign in to comment.