Skip to content

Commit

Permalink
Version 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ronmarasigan committed Dec 12, 2023
1 parent 6cf4e02 commit 4daaad7
Show file tree
Hide file tree
Showing 12 changed files with 472 additions and 192 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Ronald M. Marasigan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
85 changes: 3 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,102 +1,23 @@
## LavaLust Framework
## LavaLust 4 Development
<p align="center">
<img width="200" height="300" src="https://raw.githubusercontent.com/ronmarasigan/LavaLust-Docs/master/assets/images/logo1.png">
</p>
LavaLust is a lightweight Web Framework - (using MVC pattern) - for people who are developing web sites using PHP. It helps you write code easily using Object-Oriented Approach. It also provides set of libraries for commonly needed tasks, as well as a helper functions to minimize the amount of time coding.

## LavaLust Version 3.1.5 (latest)
<p>
Update your project using this version. You are required to use PHP v7.4 or higher.
LavaLust v3.1.5 is fully compatible to PHP8.2 and higher
</p>

## LavaLust Version 3
<p>
This version will hold the mass updates of the kernel files and built-in libraries of LavaLust Framework. It is now compatible with PHP 8.1+
</p>

## Documentation

[LavaLust Documentation Link](https://lavalust.netlify.app)
[LavaLust Documentation Link 1](https://ronmarasigan.github.io/lavalust4-docs)
[LavaLust Documentation Link 2](https://lavalust4.netlify.app)

<p>
Note: If you are using PLDT, you need to use google dns (8.8.8.8) to open the documentation website. There is
an issue with PLDT and Netlify websites.
</p>

## Changelogs of Version 3

1. Remove xss_clean() using Escaper class. If you want to use it, install htmlpurifier library then
create a function "xss_clean" inside a helper.
2. You can now use different instances of database connections. Changes also affect
the database.php file inside the config folder. (Every instances depends on the key of database array
variable.)
$this->call->database();
This will enable $this->db variable to handle queries.
$this->call->database('other_connection');
* This will open new connection based on the parameter "other_connection". You will
need to create new index in database array named "other_connection" inside database.php
file. It will enable $this->other_connection to handle queries.
3. Inside view fie, if you pass $data variable from controller, you can easily use the array key of
it inside the view.
Example: Controller

```php
function index() {
$this->call->model('user_model');
$data['users] = $this->user_model->get_all_users();
$this->call->view('user_view_file', $data);
}
```

Inside view file you can extract values of $data['users] by just using its key "users"
Example: View

```php
foreach($users as $user) {
echo $user['some_index'];
}
```

Moreover, you can also pass a plain string to view file.
Example: Controller

```php function index() {
$this->call->model('user_model');
$data = "This is a string.";
$this->call->view('user_view_file', $data);
}
```

4. In models, you dont't need to add exec() method in insert(), update() and delete() because Lavalust
automatically added it for you.
Example: model
```php
$this->db->insert($bind);
```
5. You can now use put models inside sub directories.
Example: model/sub_dir/Sample_model.php
```php
$this->call->model('sub_dir/sample');
$this->sample->method();
```
6. You can now use http verb in routes. Just add the type of request after the route
Example:
```php
$route['delete/:num']['delete'] = 'welcome/delete/$1';
```
See docs for more info.

## Installation and Tutorials

[Checkout LavaLust Tutorial's Youtube Channel](https://youtube.com/ronmarasigan)

### Special Thanks / Credits to the following

CodeIgniter
Github Comunity / Youtube for all the resouces I read to make this work.


### Licence
<p>
MIT License
Expand Down
22 changes: 22 additions & 0 deletions app/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@
*/
$config['composer_autoload'] = FALSE;

/*
|--------------------------------------------------------------------------
| Allowed URL Characters
|--------------------------------------------------------------------------
|
| This lets you specify which characters are permitted within your URLs.
| When someone tries to submit a URL with disallowed characters they will
| get a warning message.
|
| As a security measure you are STRONGLY encouraged to restrict URLs to
| as few characters as possible. By default only these are allowed: a-z 0-9~%.:_-
|
| Leave blank to allow all characters -- but only if you are insane.
|
| The configured value is actually a regular expression character group
| and it will be executed as: ! preg_match('/^[<permitted_uri_chars>]+$/i
|
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
*/
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

/*
|--------------------------------------------------------------------------
| Default Character Set
Expand Down
2 changes: 1 addition & 1 deletion app/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@
|
*/

$router->get('/', 'Welcome@index');
$router->get('/', 'Welcome::index');
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@
* Setup done? Then Hurray!
* ------------------------------------------------------
*/
require_once(SYSTEM_DIR . 'kernel/LavaLust.php');
require_once SYSTEM_DIR . 'kernel/LavaLust.php';
?>
63 changes: 32 additions & 31 deletions scheme/helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@
* @license https://opensource.org/licenses/MIT MIT License
*/

if ( ! function_exists('base_url'))
{
/**
* Base URL
*
* @return void
*/
function base_url()
{
return filter_var(BASE_URL, FILTER_SANITIZE_URL);
}
}

if ( ! function_exists('site_url'))
{
/**
* Get the site url
*
* @param string $url
* @return void
*/
function site_url($url = '')
{
$base_url = filter_var(BASE_URL, FILTER_SANITIZE_URL);
return ! empty(config_item('index_page')) ? $base_url . config_item('index_page').'/' . $url : $base_url . $url;
}
}

if ( ! function_exists('redirect'))
{
/**
Expand Down Expand Up @@ -92,34 +120,6 @@ function load_css($paths)
}
}

if ( ! function_exists('site_url'))
{
/**
* Get the site url
*
* @param string $url
* @return void
*/
function site_url($url = '')
{
$base_url = filter_var(BASE_URL, FILTER_SANITIZE_URL);
return ! empty(config_item('index_page')) ? $base_url . config_item('index_page').'/' . $url : $base_url . $url;
}
}

if ( ! function_exists('base_url'))
{
/**
* Base URL
*
* @return void
*/
function base_url()
{
return filter_var(BASE_URL, FILTER_SANITIZE_URL);
}
}

if ( ! function_exists('active'))
{
/**
Expand All @@ -131,20 +131,20 @@ function base_url()
function active($currect_page, $css_class = 'active')
{
// Explode REQUEST_URI
$uri_array = explode('/', rtrim($_SERVER['REQUEST_URI'], '/'));
$uri_array = explode('/', rtrim(strtok($_SERVER["REQUEST_URI"], '?'), '/'));
// Explode the BASE_URL
$url_array = explode('/', trim(preg_replace('(^https?://)', '', BASE_URL), '/'));
// Find the installation folder index base on $url_array
$folder_index = array_search(end($url_array), array_values($uri_array));
// Check if index_page is not empty in config file
if(! empty(config_item('index_page')))
{
// +2 to the installation folder index to get the index of controller and the rest of the segments if index_page is not empty
// +2 to the installation folder index to get the index of the route and the rest of the segments if index_page is not empty
$url = implode('/', array_slice($uri_array, $folder_index + 2));
}
else
{
// +1 to the installation folder index to get the index of controller and the rest of the segments if index_page is not empty
// +1 to the installation folder index to get the index of the route and the rest of the segments if index_page is not empty
$url = implode('/', array_slice($uri_array, $folder_index + 1));
}

Expand All @@ -170,4 +170,5 @@ function segment($seg)
}
}


?>
Loading

0 comments on commit 4daaad7

Please sign in to comment.