Download the PHP package sam-it/yii2-static-assets without Composer

On this page you can find all versions of the php package sam-it/yii2-static-assets. 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 yii2-static-assets

yii2-static-assets

Prevent publishing of assets at production time without changing your application.

Motivation

Nowadays docker is getting more and more attention and PHP applications are seeing different deployment scenarios. Where a few years ago if you split your nodes up at all you'd only split up the database server and the webserver that runs PHP as module or more recently via PHP-FPM, nowadays you want to split everything up.

Challenges

Having your webserver, for example nginx, running on a different server than PHP-FPM comes with several challenges, pros and cons:

  1. PHP can't write files and create publicly accessible URLs for them
  2. Cannot use local session storage
  3. File uploads that need to be publicly accessible need to be published to the webserver.
  4. File uploads that need to be protected have to accessible by all PHP nodes (so some kind of central storage is needed).

Solution

This extension will provide a solution for number 1 when it comes to Yii assets. The asset management system is nice when pushing changed assets directly to a server, it doesn't really work well in distributed environments though, so we need another approach.

This extension provides:

The workflow then becomes a bit different. During development the asset manager will act like a normal asset manager, publishing assets to the asset directory. When using docker-compose for the test environment you would mount the same host directory to the asset folder in the PHP container and in the webserver container.

During deployment the assetmanager simply returns URLs for assets on the assumption that they exist. Before deploying a new version of your app, you will rebuild your webserver container. This extension provides a console command that will publish all your assets to a directory of your choosing, this can then be used as part of the docker build context.

To publish your assets run the following command: `

This will create the directory build12345 inside your runtime directory and publish all assets there.

Asset discovery / publishing

Assets are discovered by recursively iterating over all folders and files. Each file that ends with .php is then processed:

Container building

To build an nignx container for server your application use this: ` You can configure the module to set some default values.

Configuration

For simple configuration use the ReadOnlyAssetManager in your application during production and development. This asset manager will use a simpler "hash" function that keeps directory structure readable. It supports $assetDevelopmentMode which allows for local asset development in a dockerized environment.

Asset development

The assumption is that you use docker-compose for local development, in which case you need to define a volume where assets are stored so that they are available in both the webserver as well as the phpfpm container: `


All versions of yii2-static-assets with dependencies

PHP Build Version
Package Version
Requires php Version >= 8.1
sam-it/docker-php Version >= 1.0.5
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 sam-it/yii2-static-assets contains the following files

Loading the files please wait ....