Download the PHP package kit-cosovan/base-frame without Composer

On this page you can find all versions of the php package kit-cosovan/base-frame. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package base-frame

Base Frame

Base Frame is a lightweight and flexible PHP framework that provides all the necessary tools for rapid web application development. It comes pre-configured so you can start creating your own views, models, and controllers right away.

Installation

Using Composer

You can install Base Frame via Composer. Add the following line to the require section of your composer.json:

Then run:

Core Components

Getting Started

  1. Create Controllers: Navigate to the app/Controllers directory and create new controller files to handle requests.
  2. Create Models: Go to the app/Models directory and create models for interacting with the database.
  3. Create Views: Head to the app/Views directory and create view files to display data.
  4. Configure Routes: Edit the config/routes.php file to set up your application's routes.

Usage Examples

Methods of Application

Application has three main methods.

  1. Method run: Starts the application.

  2. Method get: Allows you to get data from the container. It accepts two parameters get($key, $default). If the data does not exist by key, the value passed by the second parameter is returned, or null.

  3. Method set: Allows you to put data into the container. It accepts two parameters set($key, $value). Sets the value of $value by the $key.

The get and set methods are useful for debugging and storing some data throughout the application.



Methods of Cache

Cache has three main methods.

  1. Method get: Allows you to get data from the container. It accepts two parameters get($key, $default). If the data does not exist by key, the value passed by the second parameter is returned, or null.

  2. Method set: Caches data for a specific time, by default one hour. It accepts 3 parameters set($key, $data, $time). Sets data $data under $key to a time equal to $time.

  3. Method forget: Removes data from the cache. It takes one parameter forget($key). The key under which the data was written.



Methods of Controller

Controller has a method. Method render: Renders the view. Takes three parameters render($view, $data = [], $layout = ''). $view - File name (without extension: home.php = home). $data - Data passed to the view. $layout - The page template used in the view. File name (without extension: default.php = default).



Methods of Database

Before working with the databases, remember to set up the configuration files. This is mandatory.

  1. Method query: Allows you to query the database. Accepts two parameters query($query, $params = []). The query itself and the parameters, if they are required for the query. The query method excludes the possibility of SQL injection.

  2. Method get: Returns all the rows in the query.

  3. Method getOne: Returns the row as requested.

  4. Method findAll: Returns all rows from the table. Accepts one parameter findAll($tbl) - table name.

  5. Method findOne: Returns a row from the table by id. Accepts two parameters findOne($tbl, $id). $tbl - table name, $id - item id.

  6. Method findOrFail: Returns a row from the table by id. Accepts two parameters findOrFail($tbl, $id). $tbl - table name, $id - item id. If the row was not found, it returns an error.

  7. Method getInsertId: Returns the id of the string.

  8. Method rowCount: Returns the number of rows affected by the last SQL.

  9. Method getColumn: Returns the data of the requested column.

  10. Method getCount: Returns the number of rows in the table. Accepts one parameter getCount($tbl) - table name.

  11. Method getQueries: Returns all used SQL queries on the page. Useful for debugging.



Methods of Model

When creating a model, there are several mandatory variables to create.

Example of model creation:


The model has several validation rules.


  1. Method save: The save() method saves the model data to the database and returns the id of the saved row.

  2. Method update: The update() method updates the data within the database. And returns the number of rows inside the table.

  3. Method loadData: The loadData() method loads the model data. Mandatory method when creating a model.

  4. Method delete: The delete($id) method takes one argument - the id of the row to delete. Deletes the row from the database. And returns the number of rows inside the table.

  5. Method validate: The validate($data = [], $rules = []) method takes two arguments: $data is an array of validated data, $rules is an array of validation rules. By default, both parameters are equal to empty arrays. Returns true in case of successful validation and false in case of error.

  6. Method getErrors: The getErrors() method returns an array of errors.
  7. Method hasErrors: The hasErrors() method checks for errors.
  8. Method listErrors: The listErrors() method renders a list of errors.



Methods of Pagination

The Pagination class outputs us pagination and is based on bootstrap classes. If you use your own custom styles - feel free to modify the source code of the styles.


When you create a class, you are required to enter three parameters:

  1. $page - valid page.
  2. $per_page - number of entities on one page.
  3. $total - total number of entities.
    Example of creating pagination.


  1. Method getStart: The getStart() method returns the line number that starts the list of entities displayed on the page.

  2. Method getHtml: The getHtml() method returns the basic bootstrap page number markup.

    • For more convenient rendering of markup I suggest to use the following construction:
  3. Method __toString: The __toString() method converts the result returned by the getHtml() method into a string.


The Pagination class has several variables that you can use, or modify.



Methods of Request

  1. Method getPath: The getPath() method returns the url address of the current page.

  2. Method isGet: The isGet() method checks if the request method was get. It returns true if there was a get request and false otherwise.

  3. Method isPost: The isPost() method checks if the request method was post. It returns true if there was a post request and false otherwise.

  4. Method get: The get($name, $default = null) method returns the query data for the $name key, if there is no data it returns the default value $default. The query itself must be of get type.

  5. Method post: The post($name, $default = null) method returns the query data for the $name key, if there is no data it returns the default value $default. The query itself must be of post type.

  6. Method post: The post($name, $default = null) method returns the query data for the $name key, if there is no data it returns the default value $default. The query itself must be of post type.

  7. Method getData: The getData() method returns the request data as an array, where the key-value pair matches the global array $_GET or $_POST, depending on the type of request passed to the page.



Methods of Response

The Response class has two important methods.

  1. Method setResponceCode: The setResponceCode($code) method sets the response code from the server to the one you pass to it as an argument.

  2. Method redirect: The redirect($url = '') method redirects the user to the page you pass as an argument.



Methods of Router

  1. Method getRoutes: The getRoutes() method returns all routes existing in the application.

  2. Method add: The add($uri, $callback, $method) method allows your route to be processed by both the post method and the get method. The parameters passed are the url address of the route, the callback processing the route and the request method, or an array of methods.

  3. Method get: The get($uri, $callback) method allows your route to be processed by the get method. The url address of the route is passed as parameters, callback processing this route.

  4. Method post: The post($uri, $callback) method allows your route to be processed by the post method. The url address of the route is passed as parameters, callback processing this route.

  5. Method only: The only($middleware) method allows your route to be available only to a specific type of user.



Methods of Session

  1. Method setFlash: The setFlash($key, $value) method sets the warning, which is subsequently rendered using standard bootstrap markup.

  2. Method getFlash: The getFlash($key) method allows you to get the value set in the session under a specific key. It removes this value from the session.

  3. Method set: The set($key, $value) method sets a key-value pair to the global array $_SESSION.

  4. Method get: The get($key, $default = null) method returns the value set to the global array $_SESSION under a specific key. If the value was not found - returns the parameter $default.

  5. Method has: The has($key) method checks if the global array $_SESSION is set to a value under the key $key.

  6. Method forget: The forget($key) method removes a $key value from the $_SESSION global array.



Methods of View

  1. Method render: The render($view, $data = [], $layout = '') method renders the view and passes data to it. A third optional argument can be passed as a template. The third argument is initially defined as default and renders a file named default.php.

  2. Method renderPartial: The renderPartial($view, $data = []) method renders only part of the view without reloading the entire page. It also takes in the data that is passed into the view.




Helpers functions





Note

It is also worth noting that this technology works with other libraries such as: phpmailer and symfony/var-dumper. The former allows you to work with e-mail conveniently, and the latter is used for debugging.


All versions of base-frame with dependencies

PHP Build Version
Package Version
Requires symfony/var-dumper Version ^6.0
ext-pdo Version *
phpmailer/phpmailer Version ^6.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kit-cosovan/base-frame contains the following files

Loading the files please wait ....