jarir-ahmed / yii-cors-bypass
A package to replace the index.php file in a Yii application to bypass CORS policy for React and Vue.js
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jarir-ahmed/yii-cors-bypass
Requires
- php: >=7.2
README
This package replaces the default web/index.php file of a Yii2 application with a version that includes CORS headers. It allows you to work seamlessly with React or Vue.js frontends.
Useage
[ use JarirAhmed\CorsBypass\Replacer; public function actionReplaceIndex() { // Create an instance of the Replacer class $replacer = new Replacer();
try {
    // Replace the index.php file
    $replacer->replaceIndexFile();
    return $this->asJson(['message' => 'index.php replaced successfully']);
} catch (\Exception $e) {
    return $this->asJson(['error' => 'Failed to replace index.php: ' . $e->getMessage()]);
}
} ]
Installation
Run the following command to install the package via Composer:
composer require jarir-ahmed/yii-cors-bypass