- Gii – Generating Module
- Gii – Generating Controller
- Gii – Creating a Model
- Yii - Gii
- Yii - Localization
- Yii - Authorization
- Yii - Authentication
- Yii - Error Handling
- Yii - Logging
- Yii - Aliases
- Yii - Fragment Caching
- Yii - Caching
- Yii - Testing
- Yii - Fields
- Yii - RESTful APIs in Action
- Yii - RESTful APIs
- Yii - Theming
- Yii - Database Migration
- Yii - Active Record
- Yii - Query Builder
- Yii - Data Access Objects
- Yii - Database Access
- Yii - Dependency Injection
- Yii - Configurations
- Yii - Creating a Behavior
- Yii - Behaviors
- Yii - Creating Event
- Yii - Events
- Yii - GridView Widget
- Yii - ListView Widget
- Yii - Data Widgets
- Yii - Data Providers
- Yii - Properties
- Yii - Sorting
- Yii - Pagination
- Yii - Formatting
- Yii - Files Upload
- Yii - Using Cookies
- Yii - Cookies
- Yii - Using Flash Data
- Yii - Sessions
- Yii - AJAX Validation
- Yii - Ad Hoc Validation
- Yii - Validation
- Yii - HTML Forms
- Yii - Rules of URL
- Yii - URL Routing
- Yii - URL Formats
- Yii - Responses
- Yii - HTTP Requests
- Yii - Creating Extensions
- Yii - Extensions
- Yii - Asset Conversion
- Yii - Assets
- Yii - Layouts
- Yii - Views
- Yii - Modules
- Yii - Widgets
- Yii - Models
- Yii - Using Actions
- Yii - Using Controllers
- Yii - Controllers
- Yii - Entry Scripts
- Yii - Application Structure
- Yii - Create Page
- Yii - Installation
- Yii - Overview
- Yii - Home
Yii Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Yii - Apases
Apases help you not to hard-code absolute paths or URLs in your project. An apas starts with the @ character.
To define an apas you should call the Yii::setApas() method −
// an apas of a file path Yii::setApas( @apas , /path/to/apas ); // an apas of a URL Yii::setApas( @urlApas , http://www.google.com );
You can also derive a new apas from an existing one −
Yii::setApas( @pathToSomewhere , @apas/path/to/somewhere );
You can call the Yii::setApas() method in the entry script or in a writable property called apases in the apppcation configuration −
$config = [ id => basic , basePath => dirname(__DIR__), bootstrap => [ log ], components => [ apases => [ @apas => /path/to/somewhere , @urlApas => http://www.google.com , ], //other components... ] ]
To resolve apas, you should call the Yii::getApas() method.
Yii predefines the following apases −
@app − The base path of the apppcation.
@yii − The folder where the BaseYii.php file is located.
@webroot − The Web root directory of the apppcation.
@web − The base URL of the apppcation.
@runtime − The runtime path of the apppcation. Defaults to @app/runtime.
@vendor − The Composer vendor directory. Defaults to @app/vendor.
@npm − The root directory for npm packages. Defaults to @vendor/npm.
@bower − The root directory for bower packages. Defaults to @vendor/bower.
Now, add a new function called actionApases() to the SiteController −
pubpc function actionApases() { Yii::setApas("@components", "@app/components"); Yii::setApas("@imagesUrl", "@web/images"); var_dump(Yii::getApas("@components")); var_dump(Yii::getApas("@imagesUrl")); }
In the above code, we created two apases: @components for apppcation components and @imagesUrl for URL where we stored all apppcation images.
Type http://localhost:8080/index.php?r=site/apases, you will see the following output −
Advertisements