Coder Social home page Coder Social logo

yiisoft / yii2-composer Goto Github PK

View Code? Open in Web Editor NEW
86.0 23.0 30.0 9.69 MB

Yii 2 composer extension

Home Page: https://www.yiiframework.com

License: BSD 3-Clause "New" or "Revised" License

PHP 94.19% Shell 5.81%
yii yii2 composer hacktoberfest

yii2-composer's Introduction

Yii 2 Composer Installer


This is the composer installer for Yii framework 2.0 extensions. It implements a new composer package type named yii2-extension, which should be used by all Yii 2 extensions if they are distributed as composer packages.

For license information check the LICENSE-file.

Latest Stable Version Total Downloads Build status

Usage

The Yii 2 Composer Installer is automatically installed with when installing the framework via Composer.

To use Yii 2 composer installer, simply set the package type to be yii2-extension in your composer.json, like the following:

{
    "type": "yii2-extension",
    "require": {
        "yiisoft/yii2": "~2.0.0"
    },
    ...
}

You may specify a bootstrapping class in the extra section. The init() method of the class will be executed each time the Yii 2 application is responding to a request. For example,

{
    "type": "yii2-extension",
    ...,
    "extra": {
        "bootstrap": "yii\\jui\\Extension"
    }
}

The Installer class also implements a static method postCreateProject() that can be called after a Yii 2 project is created, through the post-create-project-cmd composer script. A similar method exists for running tasks after each composer install call, which is postInstall(). These methods allow to run other Installer class methods like setPermission() or generateCookieValidationKey(), depending on the corresponding parameters set in the extra section of the composer.json file. For example,

{
    "name": "yiisoft/yii2-app-basic",
    "type": "project",
    ...
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ],
        "post-install-cmd": [
            "yii\\composer\\Installer::postInstall"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ]
        },
        "yii\\composer\\Installer::postInstall": {
            "copyFiles": [
                {
                    "config/templates/console-local.php": "config/console-local.php",
                    "config/templates/web-local.php": "config/web-local.php",
                    "config/templates/db-local.php": "config/db-local.php",
                    "config/templates/cache.json": ["runtime/cache.json", true]
                }
            ],
            "generateCookieValidationKey": [
                "config/web-local.php"
            ]
        }
    }
}

yii2-composer's People

Contributors

andersonamuller avatar bwoester avatar cebe avatar creocoder avatar crtlib avatar egorpromo avatar ext4yii avatar gevik avatar gonimar avatar kartik-v avatar klimov-paul avatar lancecoder avatar larryullman avatar lucianobaraglia avatar mohorev avatar nineinchnick avatar pmoust avatar qiangxue avatar qiansen1386 avatar ragazzo avatar resurtm avatar rinatio avatar rob006 avatar samdark avatar schmunk42 avatar sensorario avatar slavcodev avatar suralc avatar tarasio avatar tonydspaniard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-composer's Issues

OPcache Exception not handled when saving extensions

What steps will reproduce the problem?

Install Yii2 in a enviroment that has the restrict_api set for the Zend OPcache
Try to use composer install, update or upgrade.
Any Yii2 packages will throw the exception

What's expected?

Succesful Installation of all the packages.

What do you get instead?

ErrorException:
Zend OPcache API is restricted by "restrict_api" configuration directive
Exception

Additional info

Q A
Yii vesion Latest
PHP version 7.3
Operating system Ubuntu running a Server Pilot instance (which is restricting the Zend OPcache)

Use composer to automatically generate translations and suggestions for migrating namespaces

We can extend the composer's configuration

{
    "type": "yii2-extension",
    ...,
    "extra": {
        "yii": {
            "name": "admin",
            "i18n": {
                "class":"yii\\i18n\\PhpMessageSource",
                "basePath":"@abc/admin/message"
            },
            "migrationNamespace": "abc\\admin\\migrations"
        }
    }
}

Then composer install will automatically generate vendor/yiisoft/i18n.php, vendor/yiisoft/ migrations.php

view vendor/yiisoft/i18n.php:

return array (
  'admin' => 
  array (
    'class' => 'yii\\i18n\\PhpMessageSource',
    'basePath' => '@abc/admin/message',
  ),
 ...,
);

view vendor/yiisoft/ migrations.php:

return array (
  0 => 'abc\\admin\\migrations',
);

In the application development, only the user manually merge the two arrays to the application configuration can be easily used.
This can be avoided in large systems or modules in more systems, due to forget or lack of configuration caused by low-level errors.

I implemented this feature in a multi-module system and automatically generated the minimum configuration for the foreground background.
Related code in https://github.com/yuncms/yii2-composer

If the review is feasible, I will create a pull.

Additional info

Q A
Yii vesion
PHP version
Operating system

Plugin yiisoft/yii2 composer couldnot be initialized class not found : yii\composer\plugin

What steps will reproduce the problem?

Used Vagrant bento/ubuntu18.04
installed PHP 7.2
installed MySQL
installed composer package
then comper install or composer update returns this error

What's expected?

To install the composer packages

What do you get instead?

throws an error like this
Plugin yiisoft/yii2 composer could not be initialized class not found: yii\composer\plugin

Additional info

composererror1

Q A
Yii version Yii2
PHP version 7.2
Operating system windows 10

update tests folder links

What steps will reproduce the problem?

http=>https

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

update root folder links

What steps will reproduce the problem?

http=>https

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

Composer 1.1.0

The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("1.0.0") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.

The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("1.0.0") ...

What steps will reproduce the problem?

composer update

What's expected?

no errors

What do you get instead?

$ composer self-update
The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("1.0.0") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.
You are already using composer version 1.1.3 (stable channel).
Skybook-Pro:hello Jeff$ composer update
The "yiisoft/yii2-composer" plugin was skipped because it requires a Plugin API version ("1.0.0") that does not match your Composer installation ("1.1.0"). You may need to run composer update with the "--no-plugins" option.

Additional info

Q A
Yii vesion
PHP version
Operating system

Does `generateCookieValidationKey()` generate the same key for every configs?

Source code: https://github.com/yiisoft/yii2-composer/blob/master/Installer.php#L268

If the extra section of composer.json is like following:

    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "common/runtime": "0777",
                    "app_1/runtime": "0777",
                    "app_2/runtime": "0777",
                    "app_1/web/assets": "0777",
                    "app_2/web/assets": "0777"
                }
            ],
            "generateCookieValidationKey": [
                "app_1/config/request.php",
                "app_2/config/request.php"
            ]
        },
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }

Then, the app_1/config/request.php and app_2/config/request.php will share the same cookie validation key when creating project.
Is it better to share the same key between two applications than use different key?

2.0.7 release?

I realize there's only one bug fix, but any chance there will be a 2.0.7 release in the not too distant future?

Some services like ServerPilot have the restrict_api setting enabled by default and several people are getting bitten by it. craftcms/cms#2834

update github folder link

What steps will reproduce the problem?

http=>https

What's expected?

What do you get instead?

Additional info

Q A
Yii vesion
PHP version
Operating system

Does not show upgrade notes on upgrade from dev version

What steps will reproduce the problem?

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 2 updates, 4 removals   
  - Removing bower-asset/jquery (2.2.4)
  - Removing bower-asset/yii2-pjax (v2.0.6)
  - Removing bower-asset/jquery.inputmask (3.3.7)
  - Removing bower-asset/punycode (v1.3.2)
  - Updating yiisoft/yii2 (2.0.11.2 => 2.0.12): Loading from cache
  - Updating cebe/assetfree-yii2 (2.0.11.2 => 2.0.12): Downloading (100%)         
Writing lock file
Generating autoload files

What's expected?

Updating yiisoft/yii2 (2.0.11.2 => 2.0.12)

should display upgrade notes from 2.0.11 to 2.0.12

What do you get instead?

no upgrade notes

Additional info

Problem seems to be that its looking for 2.0.11.2 in UPGRADE files but does not find it,
assuming no notes should be displayed.

Warning in composer

Composer is now warning us that:
The "yiisoft/yii2-composer" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).

Installer::postInstall is not callable (error on composer install)

Example here (readme):
https://github.com/yiisoft/yii2-composer
Shows "post-install-cmd": [
"yii\composer\Installer::postInstall"
]

When I attempt to configure this script to update a folder's permissions (frontend/runtime), I get error "Installer::postInstall is not callable"

(noticed there is not method 'postInstall' in class yii2-composer/Installer.php class... )

What steps will reproduce the problem?

Simply try the example posted in the readme

What's expected?

Folder's permissions to be updated

What do you get instead?

Error (see above).

A working example of how to update folder permissions using yii2-composer would be great.

Additional info

Q A
Yii version 2
PHP version 5.5
Operating system Ubuntu 14.04

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.