{"id":15025351,"url":"https://github.com/strifejeyz/framework","last_synced_at":"2025-04-09T20:03:59.016Z","repository":{"id":45930723,"uuid":"91934875","full_name":"strifejeyz/framework","owner":"strifejeyz","description":"A Fast and Lightweight PHP MVC Framework.","archived":false,"fork":false,"pushed_at":"2024-12-19T20:53:33.000Z","size":3499,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-09T20:03:51.838Z","etag":null,"topics":["mvc-architecture","mvc-framework","oop","php","php-7","pretty-urls","strife","strife-framework","template-engine"],"latest_commit_sha":null,"homepage":"https://strifejeyz.github.io/framework/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/strifejeyz.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-21T05:18:14.000Z","updated_at":"2024-12-19T21:01:56.000Z","dependencies_parsed_at":"2025-02-15T19:31:19.865Z","dependency_job_id":"a52581cd-86a3-4436-b90f-d7984b17ed4b","html_url":"https://github.com/strifejeyz/framework","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strifejeyz%2Fframework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strifejeyz%2Fframework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strifejeyz%2Fframework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/strifejeyz%2Fframework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/strifejeyz","download_url":"https://codeload.github.com/strifejeyz/framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103864,"owners_count":21048245,"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":["mvc-architecture","mvc-framework","oop","php","php-7","pretty-urls","strife","strife-framework","template-engine"],"created_at":"2024-09-24T20:02:08.572Z","updated_at":"2025-04-09T20:03:58.967Z","avatar_url":"https://github.com/strifejeyz.png","language":"PHP","readme":"# Strife PHP Framework Documentation\n\n## Introduction\nStrife is a fast and lightweight PHP MVC framework designed to simplify web application development. It provides powerful tools and features for building robust and maintainable applications.\n\n## Features\n- **Smart Routing**: Flexible and intuitive routing for handling HTTP requests.\n- **Multi-Database Support**: Compatible with various database systems.\n- **Query Builder**: Simplifies database interactions.\n- **Form Builder**: Easy generation and validation of forms.\n- **Migration Management**: Manage database schema changes effortlessly.\n- **Encryption \u0026 Caching**: Built-in tools for secure and optimized applications.\n- **Built-in CLI**: Command-line tools for rapid development.\n- **Template Engine**: For clean and maintainable HTML views.\n\n## Requirements\n- PHP 7.0 or higher\n- A web server (e.g., Apache or Nginx)\n- Composer (for dependency management)\n\n## Installation\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/strifejeyz/framework.git\n   ```\n2. Navigate to the project directory:\n   ```bash\n   cd framework\n   ```\n3. Install dependencies:\n   ```bash\n   composer install\n   ```\n\n## Directory Structure\n```\n/\n├── app/\n├── kernel/\n├── storage/\n├── vendor/\n├── .gitignore\n├── .htaccess\n├── composer.json\n├── composer.lock\n├── favicon.ico\n├── index.php\n├── LICENSE\n├── readme.md\n└── yamato\n```\n\n## Usage\n\n### Routing\nDefine routes in `app/routes.php`:\n```php\nget('/users', 'UsersController@index');\npost('/store', 'UsersController@store');\n```\n- `'/users'`: The route endpoint.\n- `UsersController@index`: The class name and method to call.\n\nYou can use either `get()` or `post()` when defining routes.\n\nTo assign a name to a route, use the following syntax:\n```php\nget('users-list -\u003e /users', 'UsersController@index');\n```\n\nIf **File-based routing** is enabled, the `app/routes.php` file is ignored. Instead, you can directly call a class and method. \nFor example, if `UsersController` is the class name and `index` is the method, you can invoke the endpoint `/users/index`. \nThis accommodates any HTTP request method.\n\n### Controllers\nCreate controllers in the `app/controllers` directory:\n```php\nuse App\\Models\\User;\n\nclass HomeController\n{\n    public function index()\n    {\n        $title = \"Home Page\";\n        $users =  User::get();\n        return render('index', compact('title','users'));\n    }\n}\n```\n\n### Models\nDefine models in the `app/models` directory:\n```php\nuse Kernel\\Database\\QueryBuilder as Model;\n\nclass User extends Model\n{\n    protected static $table = \"users\";\n}\n```\n\n### Views\nPlace your templates in `app/views`:\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003ctitle\u003e{{ $title }}\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cul\u003e\n   {{foreach($users as $user)}}\n   \u003cli\u003e{{$user-\u003efirstname}}\u003c/li\u003e\n   {{endforeach}}\n\u003c/ul\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Template Engine\nThe Strife PHP Framework includes a powerful template engine for building clean and maintainable views.\n\n#### Extending and Rendering Templates\n- **`@extend('template_name')`**: Extends a base template.\n- **`@render('template_name')`**: Renders a specified template.\n\n#### Section Management\n- **`@stop()`**: Marks the end of an extended layout/template.\n- **`@get('section_name')`**: Similar behavior to include().\n\n### Importing and Conditionals\n- **`@import('app\\models\\Users')`**: Imports a class\n- **`{{if(condition)}} ... {{endif}}`**: Executes the enclosed code block if the condition is true.\n- **`{{elseif(condition)}} ... {{endelseif}}`**: Checks an alternative condition.\n- **`{{else}}`**: Runs an alternative block if the `if` condition fails.\n- **`{{endif}}`**: Marks the end of an `if` block.\n\n#### Loops and Iterations\n- **`{{for(condition)}} ... {{endfor}}`**: Runs a block of code a specified number of times.\n- **`{{do(condition)}} ... {{enddo}}`**: Executes the enclosed block once.\n- **`{{while(condition)}} ... {{endwhile}}`**: Loops while the condition is true.\n- **`{{foreach(condition)}} ... {{endforeach}}`**: Iterates over an array or object.\n\n### Example Usage\n#### Extending a Template\n```php\n@extend('layouts/frontend')\n\n\u003cp\u003eWelcome back, user!\u003c/p\u003e\n\n@stop\n```\n\n#### Conditional Rendering\n```php\n{{if($userIsLoggedIn)}}\n    \u003cp\u003eWelcome back, user!\u003c/p\u003e\n{{else}}\n    \u003cp\u003ePlease log in.\u003c/p\u003e\n{{endif}}\n```\n\n#### Loop Example\n```php\n{{foreach($items as $item)}}\n    \u003cp\u003e{{ $item }}\u003c/p\u003e\n{{endforeach}}\n```\nUse these functions to build flexible and dynamic views efficiently.\n\n\n### Query Builder\nThis guide explains how to use the most common methods in the Query Builder class for running queries.\n\n#### `where`\nFilters results based on a condition.\n\n```php\n$query = Users::where('column_name', '=', 'value');\n```\n- **Parameters**:\n   - `field`: The column to filter.\n   - `a`: The comparison operator (e.g., `=`).\n   - `b`: The value to compare against.\n\n#### `join`\nPerforms an inner join with another table.\n\n```php\n$query = Users::join('another_table')-\u003eon('table.id = another_table.foreign_id');\n```\n- **Parameters**:\n   - `table`: The table to join.\n- **Chaining**:\n   - Use `on` to specify the join condition.\n\n#### `get`\nFetches the results of the query.\n\n```php\n$results = Users::get();\n```\n- **Parameters**:\n   - `fetchMode` (optional): Defaults to `PDO::FETCH_OBJ`.\n\n#### `select`\nSpecifies the columns to retrieve.\n\n```php\n$query = Users::select(['column1', 'column2']);\n```\n- **Parameters**:\n   - `selection`: An array of column names to select.\n\n#### `order`\nSorts the results.\n\n```php\n$query = Users::order('column_name', 'ASC');\n```\n- **Parameters**:\n   - `field`: The column to sort by.\n   - `order`: `ASC` for ascending or `DESC` for descending.\n\n#### `limit`\nLimits the number of results.\n\n```php\n$query = Users::limit(10, 5);\n```\n- **Parameters**:\n   - `number`: The maximum number of results.\n   - `offset` (optional): The starting point for the results.\n\n#### `first`\nFetches the first result of the query.\n\n```php\n$firstResult = Users::first();\n```\n\n#### `count`\nCounts the number of results.\n\n```php\n$total = Users::count();\n```\n\n#### Example Usage\nHere is an example combining some of these methods:\n\n```php\n$results = Users::select(['id', 'name'])\n    -\u003ewhere('status', '=', 'active')\n    -\u003eorder('created_at', 'DESC')\n    -\u003elimit(10)\n    -\u003eget();\n```\n\n### Database Migrations\nGenerate a migration:\n```bash\nphp yamato create:migration create_users_table\n```\nEdit the migration file and run:\n```bash\nphp yamato db:migrate\n```\n\n## Command-Line Interface (CLI)\nUse Yamato CLI for various tasks:\n```bash\nphp yamato\n```\n\n### Common Commands\n\n#### Cleanup\n- `php yamato clear:logs`: Clear logs directory.\n- `php yamato clear:cache`: Clear cached pages.\n- `php yamato clear:all`: Clear all backups, logs, and cache.\n\n#### Generators\n- `php yamato create:model [name] [table=null]`: Create a model class.\n- `php yamato create:controller [name] [empty=bool]`: Create a controller class.\n- `php yamato create:migration [name] [table]`: Create a migration class.\n- `php yamato create:request [name]`: Create a request class.\n- `php yamato create:key`: Generate an application key.\n\n#### Database\n- `php yamato db:migrate`: Install all migrations.\n- `php yamato db:rollback`: Rollback all migrations.\n- `php yamato db:backup`: Backup table data into a JSON file.\n- `php yamato db:restore`: Restore the last made backup.\n- `php yamato db:seed`: Perform database seeding.\n\n#### Security\n- `php yamato hash:encode [string]`: Returns the hash of a given string.\n- `php yamato encryption:encode [string] [level=1]`: Encrypt a string.\n- `php yamato encryption:decode [string] [level=1]`: Decrypt a string.\n\n## Contributing\nContributions are welcome! Please follow these steps:\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Submit a pull request with a detailed description of your changes.\n\n## License\nStrife is open-source software licensed under the [MIT License](LICENSE).\n\n## Support\nFor questions or support, please open an issue on [GitHub](https://github.com/strifejeyz/framework/issues).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrifejeyz%2Fframework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstrifejeyz%2Fframework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstrifejeyz%2Fframework/lists"}