Download the PHP package seguncodes/smyphp without Composer

On this page you can find all versions of the php package seguncodes/smyphp. 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 smyphp

SMYPHP

DESCRIPTION

Smyphp is a lightweight PHP framework built for developers who need a simple framework to create web applications

REQUIREMENTS

INSTALLATION

USAGE

STARTING APPLICATION

CD into your projects directory and run your application using the command below

Now you open http://localhost:8000 in your browser to see your application.

OR open with your preferred port

Now you open http://localhost:3344 in your browser to see your application.

Run the following command for help

DATABASE MIGRATION

All migration files should be saved in the migrations folder. The user_migrations.php is a default migration file and can be used as a boiler plate for creating other migration files.

To migrate the migration files, cd into your projects directory and use this command to perform a database migration

ROUTES

The routes folder contains the assets folder where css, javascript, image and other files can be stored. The routes folder also contains the index.php file which is used to handle all routing.

Rendering Pages

Rendering can be done directly in the index.php file , an example is this

Visit http://localhost:8000/hello. You're done.

OR rendering could be done using the MVC method , an example is this

index.php file

then in the ExampleController.php file

finally in the views folder, in the yourFileName.php file

Visit http://localhost:8000/hello. You're done.

Rendering Pages With Parameters

Pages can be rendered with parameters using the MVC method...

index.php file

then in the ExampleController.php file

finally in the views folder, in the yourFileName.php file

Visit http://localhost:8000/hello. You're done.

Views and Layouts

The Views folder contains the layouts folder, and also contains files that will be displayed on the browser. The layouts folder contains layouts files. NOTE: main.php file is the default file. Here is an example of defining a layout for a view file:

example.php file

In layouts folder main.php file

The {{content}} is used to display the content of example.php with the layouts from main.php file.

Defining Custom Layout for views

If you do not wish to use the main.php file to render files, then do the following:

ExampleController.php file

The $this->setLayout() function is used to set the layout for a particular page, and should be called before the rendering of the page you are setting a layout for.

Passing params into routes

Params can be passed into routes and queried in controllers, here is an example:

index.php file

then in the ExampleController.php file

$request->getParams() is used to get the parameters passed in the url

FORMS

Forms can be used in the framework using the default HTML forms or using the Framework's form builder method

Form Builder

Using the Form builder method, in any of your view files , for example a login form... in login.php in views directory

The Form::start() method is used to start the form and takes two arguments (action, method). The $form->input() method is used to call an input field in the form, it takes in two arguments (model, inputName). The model parameter is used to reference the Model handling the request for that form; while the inputName is the name for that input field.

Handling Form Data

Form data is handled using controllers. Here is an example:

in register.php in views directory

Then in index.php the route is defined

finally in the ExampleController.php file

Input Types

The form builder also comes with various input types

Custom Form Labels

The default labels of input fields in the form builder method are the inputNames of the field. The labels can be changed in the model referenced in the input() method.

in login.php in views directory

in the model being referenced in the controller handling the form data, there is a labels() method, where the labels can be customized

Model.php

SQL QUERIES

Writing SQL queries in the framework can be achieved using the framework's query builders or default SQL statements

Query Builders

The framework comes with various query builders save() The save function saves data into database findOne() finds row WHERE argument exists and returns only 1

findOneOrWhere() This takes in two arguments with an OR condition

findAll() This performs the basic SELECT all functionality in descending order of id

findAllWhere() This performs the findAll functionality with a WHERE clause

findAllOrWhere() This performs the findAll functionality with a WHERE clause and an OR condition

count() This counts the number of columns in a table

countWhere() This counts the number of columns with a WHERE clause

countOrWhere() This counts the number of columns with a WHERE clause and an OR condition

delete() This takes a WHERE clause and deletes a row or rows

deleteOrWhere() This takes a WHERE clause and deletes a row or rows

update() This takes two arguments, the data to be updated and a WHERE clause

updateOrWhere() This takes three arguments, the data to be updated, a WHERE clause and an OR condition

Writing Custom SQL queries

Unlike using the query builders, custom SQL statements can be written, here is an example:

MIDDLEWARES

The framework includes a middleware that verifies if the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to your application's login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.

The first middleware ApiMiddleware is used to check for authenticated users on your api and it is called in the controller, the method handling the route that should not be accesible by the user is passed in array of new Authenticate(['']).

In ExampleController.php file

The second middleware Authenticate middleware is called in the controller and it's used when dealing with dynamic webpages on the framework, the method handling the route that should not be accesible by the user is passed in array of new Authenticate(['']).

In ExampleController.php file

To prevent a user from accessing a page after login, add the following code to the top of the file rendering that page; or to set restrictions for users who are logged in or not

The isGuest() function is used to check if there is an existing session

SENDING MAIL

Sending mails in the framework is achieved using PHPMAILER. To send a mail from the controller , the MailServiceProvider class is called.

in ExampleController.php file

To send an hand coded mail, the MailServiceProvider.php file in the app/Providers directory can be edited

Flash Messages

Sending flash messages after a successful request can be achieved from the controller by calling the setflash() method which takes in two arguments (key, message). in ExampleController.php file

Image Conversion

When dealing with images using the framework, the image file has to be sent in base64 format to the backend API. To convert an image from the base64 format , the Image class is called.

in ExampleController.php file

To use the Image class , make sure the extension=gd in your php.ini file is enabled.

Sending Json responses in API

To send json responses in API using the framework is quite simple and very similar to most php frameworks

in ExampleController.php file

The json method takes two arguments, the array data to be returned and the status code

Getting Authenticated user in API

Getting the authenticated user in your API on the framework is quite simple and similar to most php frameworks in ExampleController.php file

Auth::User() returns the id of the authenticated user.

Contributing & Vulnerabilities

If you would like to contribute or you discover a security vulnerability in the SmyPhp FrameworK, your pull requests are welcome. However, for major changes or ideas on how to improve the library, please create an issue.

License

The SmyPhp framework is open-sourced software licensed under the MIT license.


All versions of smyphp with dependencies

PHP Build Version
Package Version
Requires vlucas/phpdotenv Version ^5.4
phpmailer/phpmailer Version ^6.6
firebase/php-jwt Version ^6.3
filp/whoops Version ^2.14
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 seguncodes/smyphp contains the following files

Loading the files please wait ....