{"id":21557040,"url":"https://github.com/nicehalf/nicehalf-framework","last_synced_at":"2026-03-02T17:34:01.323Z","repository":{"id":53265283,"uuid":"489551001","full_name":"NICEHALF/NiceHalf-Framework","owner":"NICEHALF","description":"NiceHalf Framework is an open source PHP Framework ready for production","archived":false,"fork":false,"pushed_at":"2022-08-01T00:58:08.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-24T09:11:35.184Z","etag":null,"topics":["framework","pdo","php-framework","php7","php8"],"latest_commit_sha":null,"homepage":"https://nicehalf.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NICEHALF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-07T02:53:06.000Z","updated_at":"2024-05-25T09:58:11.000Z","dependencies_parsed_at":"2022-08-27T06:21:12.815Z","dependency_job_id":null,"html_url":"https://github.com/NICEHALF/NiceHalf-Framework","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NICEHALF%2FNiceHalf-Framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NICEHALF%2FNiceHalf-Framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NICEHALF%2FNiceHalf-Framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NICEHALF%2FNiceHalf-Framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NICEHALF","download_url":"https://codeload.github.com/NICEHALF/NiceHalf-Framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199086,"owners_count":21063641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","pdo","php-framework","php7","php8"],"created_at":"2024-11-24T08:10:45.301Z","updated_at":"2026-03-02T17:34:01.278Z","avatar_url":"https://github.com/NICEHALF.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# NiceHalf Framework \"Ready For Production\"\r\n\r\nNiceHalf Framework is an open source PHP Framework ready for production\r\n\r\n## Installation\r\n\r\nUse [Composer](https://getcomposer.org) to install NiceHalf Framework.\r\n\r\n```bash\r\ncomposer create-project nicehalf/nicehalf-framework\r\n```\r\n\r\n## Usage of Application :\r\n\r\n```php\r\n# Get composer autoload\r\nrequire __DIR__ . '/../vendor/autoload.php';\r\n\r\n# Get application class\r\nrequire __DIR__ . '/../system/Applications/Application.php';\r\n\r\n# Run the app\r\nApplication::run();\r\n```\r\n\r\n## Usage of Cookie :\r\n\r\n```php\r\n# Get cookie class\r\nrequire __DIR__ . '/../system/Cookies/Cookie.php';\r\n\r\n# Or use import cookie class\r\nuse NicehalfCore\\System\\Cookies\\Cookie;\r\n\r\n# Set cookie , you can set expire time by edit the third parameter \r\nCookie::set('name', 'value');\r\n\r\n# Check that cookie has the key\r\nif (Cookie::has('name')) {\r\n    echo 'has cookie';\r\n}\r\n\r\n# Get cookie by the given key\r\necho Cookie::get('name');\r\n\r\n# Delete cookie by the given key\r\nCookie::delete('name');\r\n\r\n# Return all cookies\r\nprint_r(Cookie::all());\r\n\r\n# Destroy all cookies\r\nCookie::destroy();\r\n```\r\n\r\n## Usage of Session :\r\n\r\n```php\r\n# Get session class\r\nrequire __DIR__ . '/../system/Sessions/Session.php';\r\n\r\n# Or use import session class\r\nuse NicehalfCore\\System\\Sessions\\Session;\r\n\r\n# Start session\r\nSession::start();\r\n\r\n# Set session\r\nSession::set('name', 'value');\r\n\r\n# Check that session has the key\r\nif (Session::has('name')) {\r\n    echo 'has session';\r\n}\r\n\r\n# Get session by the given key\r\necho Session::get('name');\r\n\r\n# Delete session by the given key\r\nSession::delete('name');\r\n\r\n# Return all sessions\r\nprint_r(Session::all());\r\n\r\n# Get flash session by the given key\r\nSession::flash('name');\r\n\r\n# Destroy all sessions\r\nSession::destroy();\r\n```\r\n\r\n## Usage of Database :\r\n\r\n```php\r\n# Get database class\r\nrequire __DIR__ . '/../system/Database/Database.php';\r\n\r\n# Or use import database class\r\nuse NicehalfCore\\System\\Database\\Database;\r\n\r\n# Connect to database\r\n# Database connection start only when you call a method and you can use the following methods :\r\n\r\n# Select\r\nDatabase::table('table_name')-\u003eselect('column_name');\r\n\r\n# Insert\r\nDatabase::table('table_name')-\u003einsert(['column_name' =\u003e 'value'])-\u003eexecute();\r\n\r\n# Update\r\nDatabase::table('table_name')-\u003eupdate(['column_name' =\u003e 'value'])-\u003ewhere('column_name', '=', 'value');\r\n\r\n# Delete\r\nDatabase::table('table_name')-\u003edelete()-\u003ewhere('column_name', '=', 'value');\r\n\r\n# To join table\r\nDatabase::table('table_name')-\u003ejoin('table_name', 'table_name.column_name', '=', 'table_name.column_name');\r\n\r\n# To join table on left\r\nDatabase::table('table_name')-\u003eleftJoin('table_name', 'table_name.column_name', '=', 'table_name.column_name');\r\n\r\n# To join table on right\r\nDatabase::table('table_name')-\u003erightJoin('table_name', 'table_name.column_name', '=', 'table_name.column_name');\r\n\r\n# Usage of where\r\nDatabase::table('table_name')-\u003ewhere('column_name', '=', 'value');\r\n\r\n# Usage of orWhere \r\nDatabase::table('table_name')-\u003eorWhere('column_name', '=', 'value');\r\n\r\n# Filter string : filtring inputs is automatically handled by the framework\r\n\r\n# Usage of groupBy\r\nDatabase::table('table_name')-\u003egroupBy('column_name');\r\n\r\n# Usage of orderBy\r\nDatabase::table('table_name')-\u003eorderBy('column_name', 'asc');\r\n\r\n# Usage of limit\r\nDatabase::table('table_name')-\u003elimit(10);\r\n\r\n# Usage of offset\r\nDatabase::table('table_name')-\u003eoffset(10);\r\n\r\n# Usage of having\r\nDatabase::table('table_name')-\u003ehaving('column_name', '=', 'value');\r\n\r\n# Usage of get\r\nprint_r(Database::table('table_name')-\u003eget());\r\n\r\n# Get first row\r\nprint_r(Database::table('table_name')-\u003efirst());\r\n\r\n# Usage of count\r\nprint_r(Database::table('table_name')-\u003ecount());\r\n\r\n# Usage of patination\r\nprint_r(Database::table('table_name')-\u003epaginate(10));\r\n\r\n# Get links for pagination\r\nprint_r(Database::table('table_name')-\u003elinks()); // use it in view\r\n\r\n# Usage of clear\r\nDatabase::table('table_name')-\u003eclear(); // automatically handled by the framework\r\n```\r\n\r\n## Usage of Exception :\r\n\r\n```php\r\n# Get exception class\r\nrequire __DIR__ . '/../system/Exeptions/Whoops.php';\r\n\r\n# Or use import exception class\r\nuse NicehalfCore\\System\\Exeptions\\Whoops;\r\n\r\n# Throw exception\r\nthrow new Exception('message');\r\n```\r\n\r\n# Usage of File :\r\n\r\n```php\r\n# Get file class\r\nrequire __DIR__ . '/../system/Extra/File.php';\r\n\r\n# Or use import file class\r\nuse NicehalfCore\\System\\Extra\\File;\r\n\r\n# Get Root path\r\necho File::root();\r\n\r\n# Get directory separator\r\necho File::ds();\r\n\r\n# Get file full path\r\necho File::path('path/to/file');\r\n\r\n# Check if file exists\r\necho File::exist('path/to/file');\r\n\r\n# Require file\r\nFile::require_file('path/to/file');\r\n\r\n# Include file\r\nFile::include_file('path/to/file');\r\n\r\n# Require directory\r\nFile::require_directory('path/to/dir');\r\n```\r\n\r\n## Usage of Message : Using Bootstrap\r\n\r\n```php\r\n# Get message class\r\nrequire __DIR__ . '/../system/Extra/Messages.php';\r\n\r\n## Or use import message class\r\nuse NicehalfCore\\System\\Extra\\Messages;\r\n\r\n## Set Error Message\r\nMessages::error('message');\r\n\r\n## Set Success Message\r\nMessages::success('message');\r\n\r\n## Set Info Message\r\nMessages::info('message');\r\n\r\n## Set Warning Message\r\nMessages::warning('message');\r\n```\r\n\r\n## Usage of Url :\r\n\r\n```php\r\n# Get url class\r\nrequire __DIR__ . '/../system/Extra/Url.php';\r\n\r\n# Or use import url class\r\nuse NicehalfCore\\System\\Extra\\Url;\r\n\r\n# Get path\r\necho Url::path($path);\r\n\r\n# Get current url\r\necho Url::getCurrentUrl();\r\n\r\n# Go to previous url\r\nUrl::previous();\r\n\r\n## Redirect to url\r\nUrl::redirect('url');\r\n```\r\n\r\n## Usage of Request :\r\n\r\n```php\r\n# Get request class\r\nrequire __DIR__ . '/../system/Http/Request.php';\r\n\r\n# Or use import request class\r\nuse NicehalfCore\\System\\Http\\Request;\r\n\r\n# Get Base Url\r\necho Request::baseUrl();\r\n\r\n# Get full url\r\necho Request::full_url();\r\n\r\n# Check that the request has the key\r\nif (Request::has('name')) {\r\n    echo 'has request';\r\n}\r\n\r\n# Get the value from the request by the given key and method\r\necho Request::value('name', 'post');\r\n\r\n# Get value from get request\r\necho Request::get('name');\r\n\r\n# Get value from post request\r\necho Request::post('name');\r\n\r\n# Set value for request by the given key\r\nRequest::set('name', 'value');\r\n\r\n# Get previous request value\r\necho Request::previous();\r\n\r\n# Get all requests\r\nprint_r(Request::all());\r\n```\r\n## Usage of Response :\r\n\r\n```php\r\n# Get response class\r\nrequire __DIR__ . '/../system/Http/Response.php';\r\n\r\n# Or use import response class\r\nuse NicehalfCore\\System\\Http\\Response;\r\n\r\n# Set response header\r\nResponse::header('Content-Type', 'text/html'); \r\n\r\n# Set response status code\r\nResponse::status(200);\r\n\r\n# Return json respoonse\r\nResponse::json(['name' =\u003e 'value']);\r\n\r\n# Output data : accept string, array, object\r\nResponse::output('data');\r\n```\r\n\r\n## Usage of Server :\r\n\r\n```php\r\n# Get server class\r\nrequire __DIR__ . '/../system/Http/Server.php';\r\n\r\n# Or use import server class\r\nuse NicehalfCore\\System\\Http\\Server;\r\n\r\n# Check that server has the key\r\nif (Server::has('name')) {\r\n    echo 'has server';\r\n}\r\n\r\n# Get the value from server by the given key\r\necho Server::value('name');\r\n\r\n# Get path info\r\necho Server::path_info();\r\n\r\n# Get all server data\r\nprint_r(Server::all());\r\n```\r\n\r\n## Usage of Model :\r\n\r\n```php\r\n# Get model class\r\nrequire __DIR__ . '/../system/Models/Model.php';\r\n\r\n# Or use import model class\r\nuse NicehalfCore\\System\\Models\\Model;\r\n\r\n# you can use the model class to create your own model for your application , for example : create a model for user and on the model you can create your own methods and set the table name without using Database class\r\n\r\n# for example without using model :\r\n# Database::table('users')-\u003ewhere('id', '=', 1)-\u003efirst();\r\n\r\n# for example with model :\r\n# Model::where('id', '=', 1)-\u003efirst();\r\n```\r\n\r\n## Usage of Route :\r\n\r\n```php\r\n# Get route class\r\nrequire __DIR__ . '/../system/Routers/Route.php';\r\n\r\n# Or use import route class\r\nuse NicehalfCore\\System\\Routers\\Route;\r\n\r\n# Set route on get method\r\nRoute::get('/', function () {\r\n    return 'Hello World';\r\n});\r\n# or\r\nRoute::get('/', \"Controller@method\");\r\n\r\n# Set route on post method\r\nRoute::post('/', function () {\r\n    return 'Hello World';\r\n});\r\n# or\r\nRoute::post('/', \"Controller@method\");\r\n\r\n# Set route on both methods\r\nRoute::any('/', function () {\r\n    return 'Hello World';\r\n});\r\n# or\r\nRoute::any('/', \"Controller@method\");\r\n\r\n# Usage of prefix on get or post method\r\nRoute::prefix('admin', function () {\r\n    Route::get('dashboard', function () {\r\n        return 'Hello World';\r\n    });\r\n    # or\r\n    Route::get('dashboard', \"Controller@method\");\r\n});\r\n\r\n# Usage of middleware\r\nRoute::middleware('auth', function () {\r\n    Route::get('dashboard', function () {\r\n        return 'Hello World';\r\n    });\r\n    # or\r\n    Route::get('dashboard', \"Controller@method\");\r\n});\r\n\r\n# Get All routes\r\nprint_r(Route::all());\r\n```\r\n## Usage of View :\r\n\r\n```php\r\n# Get view class\r\nrequire __DIR__ . '/../system/Views/View.php';\r\n\r\n# or use import view class\r\nuse NicehalfCore\\System\\Views\\View;\r\n\r\n# render view by class\r\nView::render('view', ['name' =\u003e 'value']);\r\n\r\n# render view by helper\r\nview('view', ['name' =\u003e 'value'], 'helper');\r\n\r\n# you can use blade template engine or basic method to render view\r\n# blade template engine is the default method\r\n# to change the method you can go to view class and change the method\r\n\r\n# example of blade template engine :\r\npublic static function render($path, $data = [])\r\n{\r\n    $errors = Session::flash('errors');\r\n    $old = Session::flash('old');\r\n    $data = array_merge($data, ['errors' =\u003e $errors, 'old' =\u003e $old]);\r\n\r\n    return static::bladeRender($path, $data);\r\n}\r\n\r\n# example basic method :\r\npublic static function render($path, $data = [])\r\n{\r\n    $errors = Session::flash('errors');\r\n    $old = Session::flash('old');\r\n    $data = array_merge($data, ['errors' =\u003e $errors, 'old' =\u003e $old]);\r\n\r\n    return static::viewRender($path, $data);\r\n}\r\n```\r\n\r\n## Usage of Validator :\r\n\r\n```php\r\n# Get validator class\r\nrequire __DIR__ . '/../system/Validations/Validator.php';\r\n\r\n# Or use import validator class\r\nuse NicehalfCore\\System\\Validations\\Validator;\r\n\r\n# Validate data\r\n$validator = Validator::make($data, [\r\n    'name' =\u003e 'required|min:3',\r\n    'email' =\u003e 'required|email',\r\n    'password' =\u003e 'required|min:6',\r\n]);\r\n```\r\n\r\n## Contributing\r\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\r\n\r\nPlease make sure to update tests as appropriate.\r\n\r\n## Version\r\n1.0.0\r\n\r\n## Author\r\nDeveloped by Ayoub Bablil.\r\n\r\n## Email\r\nayoubbablil@gmail.com\r\n\r\n## Website\r\nhttps://nicehalf.com\r\n\r\n## License\r\nThe framework is open-sourced software licensed under the [MIT](https://choosealicense.com/licenses/mit/) license.# NiceHalf-Framework\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicehalf%2Fnicehalf-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicehalf%2Fnicehalf-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicehalf%2Fnicehalf-framework/lists"}