Or everywhere in yii2 phpexcel
Trying to learn and help some other programmers to find their solutions on the Yii Forum (I think is a superb way to learn the framework), I was facing one challenge with an external library that a fellow programmer wanted to use -quite good indeed: PHPExcel. And what is PHPExcel?
PHPExcel - OpenXML - Create Excel2007 documents in PHP - Spreadsheet engine
Project providing a set of classes for the PHP programming language, which allow you to write to and read from different file formats, like Excel 2007, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP. Checkout the [Features] (http://phpexcel.codeplex.com/wikipage?title=Features) this class set provides, such as setting spreadsheet meta data (author, title, description, ...), multiple worksheets, different fonts and font styles, cell borders, fills, gradients, adding images to your spreadsheet and much, much more!
The fellow programmer (Jack Fiallos) had a problem of using the libraries within Yii. He was surprised that he could easily use the libraries outside of the framework but not within the framework itself. At first we didn't think about it but suddenly we thought about the autoloading features of Yii and looked into the guts of PHPExcel to find out what was causing the problems.
We were right, PHPExcel has an autoloading feature itself that when a classes is called (i.e. PHPExcel_Shared_ZipStreamWrapper) the first part of the name is actually reflecting the folder's path where the class is located (i.e. PHPExcel_Shared_ZipStreamWrapper = PHPExcel / Shared_ZipStreamWrapper.php). Please review the following code (extracted from PHPExcel_Autoloader class):
First solution: disabling Yii's Autoload
The workaround to this problem (at least the one I know) is by making use of the spl_autoload_register and spl_autoload_unregister PHP's functions. The following code shows how we got the library working -I assume that you have downloaded the PHPExcel files, unzipped its contents and place them into a phpexcel folder within your application's protected / extensions folder:
Second solution: patching PhpExcel
The previous solution has an annoying consequence: one can't easily mix Yii's classes within a code that uses PHPExcel. Fortunately, there is a solution with no such side effect.
In "Classes / PHPExcel / Autoloader.php", replace the line
See the documentation of spl_autoload_register for a description of these parameters.
This post is using PHPExcel external library as an example, but this procedure should be taken into account when we encounter a problem like this. Whenever you find a library that you wish to include in your Yii application, check out its autoloading functions first.
- Disagree as to who loves female anatomy
- What is a Sony 3D sync transmitter
- How to cheat on the roll20 virtual tabletop
- If87127 standards-based mathematical parts and whole
- Learn how to use the prison language glossary sabela
- Hasselblad 50mm f4 as well
- What is a broad disc bulge
- How to adjust the vw crankshaft end play
- Railway stations between Howrah and Bandel
- A CO2 cartridge is leaking when installed in the gun
- The one who walks alone
- I estas tentando remix descargar whatsapp
- How to make mullet bait for bream
- What is the perfect man size Kleenex
- What is Sky News Frequency
- Who accentuates competitors
- Prepackaged Sandwiches Wholesaler Oregon
- What is the biggest shark tooth ever found
- Attending 2pac funeral
- What size mesh pot for basil
- Who has the best roundhead gamefowl
- What is called Ramphal Fruit in English
- Diproderm cream 15g is like many ounces
- What is the gross internal area