Download the PHP package samsin33/laravel-foundation without Composer

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

Introduction

Foundation package for laravel version 9 and 10. This package provide foundation for laravel to use its features more smoothly.

Installation

Just install samsin33/laravel-foundation package with composer.

Foundation Model

This package is developed to use the Eloquent features in most awesome way:
To create model use the foundation:make-model command. This command will also take additional attributes like --controller, etc. which are there in the laravel documentation.

The Post model will be created in your app/Models folder which extends the Samsin33\Foundation\Models\BaseModel class.
Samsin33\Foundation\Models\BaseModel class extends the Illuminate\Database\Eloquent\Model class, so you can do all the functionalities of eloquent model.

Importance

The foundation model performs the below features in very simple way.

Validations

To create validations for a model just define function getValidationRules() this should return the validation array.
To define the custom validation messages define function getValidationMessages() which will also return array of validation messages.
To get error messages use Eloquent object errors(), E.g. $post->errors()->all().

Sometimes if you do not want to validate data use saveWithoutValidate(). Sometimes we wish to validate some fields conditionally, E.g. password, status, etc. Use setValidationType(), removeValidationType() and isValidationType() in that case.

Note: The validation is happening in the saving event, so it will be called every time in the while creating or updating an Eloquent object.

Events

Laravel Eloquent has 14 events which are: retrieved, creating, created, updating, updated, saving, saved, deleting, deleted, trashed, forceDeleted, restoring, restored, and replicating. To use events in model you just need to define the event name followed by Event function. E.g. savingEvent(), updatedEvent(), deletingEvents().

In the *ing events the operation will stop if you return false.

Note: The validations are happening in the savingEvent() so call the parent::savingEvent() in that and make sure to return false if parent::savingEvent() is false.

Queue

If you want to push something to queue call the dispatchQueue(). This function will take 2 arguments 1st is the function name and 2nd is the data array.
You need to define the function by the name given in the 1st argument with $data argument.
If you want to use the current user attributes in that function at the time post delete() is called use $this->queue_user attribute.
In the above example lets delete all post comments on queue.

Cache

The CacheTrait contains very useful functions which makes caching very simple.
Suppose there is a Category model where you want to cache the active and inactive categories.
You need to update the $is_cached, $cache_fields, $cache_conditions attributes.

The $is_cached should be set to true if caching needs to be enabled to that model.
The $cache_fields contains the attributes which needs to be fetched in getCache().
And $cache_conditions must be an array where the key of array is the cache key and its value should also be the array which needs to pass in the where condition if the model as in example given below.

Mail

MailerTrait contains the sendMail() which will send the email. The function will take the following arguments:
$email_to,
string $view,
string $subject = '', (optional)
array $data = [], (optional)
array $cc = [], (optional)
array $bcc = [], (optional)
int $reset_email_from = 0, (optional)
array $attach = [], (optional)
array $reply_to = []. (optional)

In the view file you can access the attributes with $data variable.
$data will contain 2 keys:
$data['object'] - which contains the model object.
$data['other_data'] - contains the value in the above $data argument passed in sendMail().

You can also send the exception email by using function sendExceptionEmail() in which case you need to add the exception_email key in your mail config file.
The 1st argument take $exception variable which can be an array. The $exception data will be available in your view file as $data['other_data'].

Note: You can use MailerTrait in Exceptions/Handler.php file also to call exception email function.

Other Traits

Some other useful traits are:
UserSessionTrait
RequestTypeTrait
DateTrait
GuzzleHttpTrait

To get current user details you can use:
currentUser()
currentUserId()

You can check out the other traits to use their functions.


All versions of laravel-foundation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.2
illuminate/log Version ^9.0|^10.0
illuminate/notifications Version ^9.0|^10.0
illuminate/console Version ^9.0|^10.0
illuminate/container Version ^9.0|^10.0
illuminate/contracts Version ^9.0|^10.0
illuminate/database Version ^9.0|^10.0
illuminate/encryption Version ^9.0|^10.0
illuminate/http Version ^9.0|^10.0
illuminate/support Version ^9.0|^10.0
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 samsin33/laravel-foundation contains the following files

Loading the files please wait ....