Skip to content

Commit

Permalink
2.3.2 Fixed lemonade
Browse files Browse the repository at this point in the history
  • Loading branch information
tenmajkl committed Jun 26, 2021
1 parent 769f05a commit 845d6fa
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Lemon

Lemon is php micro framework built for simple applications.\
Latest version: 2.3.1\
Latest version: 2.3.2\
Documentation: https://lemon-framework.github.io//docs.html

# Installation
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"files": [
"src/Views/views.php",
"src/Http/Routing/Route.php",
"src/Utils/utils.php"
"src/Utils/utils.php",
"src/Kernel/loader.php"
]
}
}
20 changes: 0 additions & 20 deletions lemonade

This file was deleted.

7 changes: 3 additions & 4 deletions src/Kernel/Lemonade/Builders/builder.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

require "templates.php";
require "licenses.php";

/*
Expand Down Expand Up @@ -58,7 +57,7 @@ private function parse($arguments)
* */
public function execute()
{
global $types;
$types = TYPES;
$arguments = $this->parse($this->arguments);
if (!isset($arguments["type"]))
{
Expand All @@ -81,8 +80,8 @@ public function execute()
* */
private function project()
{
global $dirs;
global $files;
$dirs = DIRS;
$files = FILES;

echo textFormat("\nBuilding project...\n\n", "33");
foreach ($dirs as $dir)
Expand Down
4 changes: 2 additions & 2 deletions src/Kernel/Lemonade/Builders/licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
* */
private function licenseType()
{
global $licenses;
$licenses = LICENSES;
$type = readline("Type license you want to build: ");

if (isset($licenses[$type]))
Expand Down Expand Up @@ -82,7 +82,7 @@ private function licenseAuthor()
* */
public function buildLicense()
{
global $licenses;
$licenses = LICENSES;
$file = fopen("LICENSE.md", "w");
$license = $this->parameters["license"];

Expand Down
10 changes: 5 additions & 5 deletions src/Kernel/Lemonade/Builders/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
* */

// List of supported arguments
$arg_list = [
const ARG_LIST = [
"type",
];

// List of builder types
$types = [
const TYPES = [
"project",
"license"
];


// List of project directories
$dirs = [
const DIRS = [
"public",
"views",
"routes",
"controllers",
];

// List of project files
$files = [
const FILES = [
"public/index.php" => "https://raw.githubusercontent.com/Lemon-Framework/Examples/master/templates/index.php",
"routes/web.php" => "https://raw.githubusercontent.com/Lemon-Framework/Examples/master/templates/web_routes.php"
];


// List of supported licenses
$licenses = [
const LICENSES = [
"mit" => "https://raw.githubusercontent.com/Lemon-Framework/Examples/master/templates/licences/mit.txt",
"apache" => "https://raw.githubusercontent.com/Lemon-Framework/Examples/master/templates/licences/apache.txt"

Expand Down
2 changes: 1 addition & 1 deletion src/Kernel/Lemonade/Helpers/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* List of all commands
*
* */
$commands = [
const COMMANDS = [
"-h" => "help",
"-i" => "info",
"-v" => "version",
Expand Down
12 changes: 5 additions & 7 deletions src/Kernel/Lemonade/Helpers/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "helpers.php";

// List of all commands
$help = "
const HELP = "
-h Shows this help
-i Shows info about lemon
-v Shows version of Lemon
Expand All @@ -15,22 +15,20 @@
";

$version = "2.1.1";
const VERSION = "2.3.1";

// Shows help
function help()
{
global $help;

echo textFormat("\n\u{1F34B} Lemon help\n", "33");
echo $help;
echo HELP;

}

// Shows info about project
function info()
{
global $version;
$version = VERSION;

echo textFormat("\n\u{1F34B} Lemon info\n", "33");
echo "\nLemon is simple micro framework that provides routing, etc.\n";
Expand All @@ -40,7 +38,7 @@ function info()
// Show version
function version()
{
global $version;
$version = VERSION;

echo textFormat("\n\u{1F34B} Lemon version\n", "33");
echo "\n->{$version}\n";
Expand Down
8 changes: 5 additions & 3 deletions src/Kernel/Lemonade/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@
class Kernel
{
private $command;
private $directory;

public function __construct($command)
public function __construct($command, $directory)
{
$this->command = $command;
$this->directory = $directory;
}

public function execute()
{
$command = isset($this->command[1]) ? $this->command[1] : "";
$arguments = array_slice($this->command, 2);
global $commands;
isset($commands[$command]) ? $commands[$command]($arguments) : $commands["-h"]();
$commands = COMMANDS;
isset($commands[$command]) ? $commands[$command]($arguments, $this->directory) : $commands["-h"]();

}

Expand Down
11 changes: 6 additions & 5 deletions src/Kernel/Lemonade/Server/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class Server
{
private $arguments;
private $directory;
private $arg_list = [
"port",
"host"
Expand All @@ -19,10 +20,10 @@ class Server
* Takes arguments
*
* */
public function __construct($arguments)
public function __construct($arguments, $directory)
{
$this->arguments = $arguments;

$this->directory = $directory;
}

/*
Expand Down Expand Up @@ -56,7 +57,7 @@ private function build()

$address = isset($arguments['host']) ? $arguments['host'] : "localhost";
$port = isset($arguments['port']) ? $arguments['port'] : "8000";
$dir = __DIR__ . "/../../../../public/";
$dir = $this->directory."/public/";

$command = "php -S {$address}:{$port} -t {$dir}";
return $command;
Expand Down Expand Up @@ -87,9 +88,9 @@ public function run()
* Function for command registration
*
* */
function serve($arguments)
function serve($arguments, $directory)
{
$server = new Server($arguments);
$server = new Server($arguments, $directory);

$server->run();
}
Expand Down
3 changes: 0 additions & 3 deletions src/Kernel/loader.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<?php

namespace Lemon\Kernel;

/*
*
* Loads all routes from routes folder
Expand Down

0 comments on commit 845d6fa

Please sign in to comment.