Where is PHPExcel.php file located - php

I want to create an excel file in my phalcon php app. I've downloaded PHPExcel, but I am not able to find where the PHPExcel.php file is located. Could anyone tell me where it is?

You can put the library folder (PHPExcel/Classes/) phalcon_project/app/library/.
To use the class, you must use the method of registerDirs \Phalcon\Loader
See more in create Excel file in Phalcon php framework

In the downloaded zip file PHPExcel_1.7.9_doc.zip, there is a folder called Classes, there you can find PHPExcel.php. You only need to insert the whole Classes folder and include PHPExcel.php for a correct implementation.

Related

require_once(PHPExcel/Classes/PHPExcel.php): failed to open stream

I am trying to include PHPExcel to a Silverstripe 3 site to export excel sheets. Right now I am just trying to test, but I get this error when trying to do it:
[Warning] require_once(/sitename/mysite/AddOns/PHPExcel/Classes/PHPExcel.php): failed to open stream: No such file or directory
Thing is I know this file exists since I copied it over myself and have rechecked the path over and over. So I decided "well check if the file exists" using this code:
if(!file_exists(Director::baseURL().'mysite/AddOns/PHPExcel/Classes/PHPExcel.php')) {
echo 'sdf';exit;
}
The path is correct (that is where it is saved) according to the error, but- file does not exist. I am also requiring the file in the same way, with no luck
require_once Director::baseURL().'mysite/AddOns/PHPExcel/Classes/PHPExcel.php';
I have tried everything-checking file permissions, referencing parent folders using ../../, calling it directly like AddOns/PHPExcel, moving it to this new AddOns folder (first tried placing the PHPExcel classes on the root and discovered that Silverstripe doesn't read it then :) )
I know I am doing something wrong but for the life of me I cannot see what. Please help
Thanks
BASE_PATH is the best way to access the web root folder.
require_once(BASE_PATH . '/AddOns/PHPExcel/Classes/PHPExcel.php');
Also this is only an issue if you are not using composer, to solve this issue in the correct way you should use composer.
You should consider using composer to include the PHPExcel class, this will avoid the need to manually require the class and will help you with dependency management.
composer require phpoffice/phpexcel
As pointed out Director::baseURL() will return the URL rather than the filepath.
Instead require relative to the file web root like so:
require_once(BASE_PATH . '/AddOns/PHPExcel/Classes/PHPExcel.php');
As pointed out by both Dan and Barry in the other answers, it's preferable to use composer for dependency management.

Where to put my .txt files for PHP to read them in Laravel

I am creating a small application that is going to read .txt files and put each row of text in the database. I am not sure where to put those .txt files so that it's in accordance with Laravel standards. Should I put those files in the /public/ directory and access them from a controller via public_path() helper function?
The documentation seems to omit that information. I'd appreciate any help.
When using the local driver, note that all file operations are relative to the root directory defined in your configuration file. By default, this value is set to the storage/app directory. Therefore, the following method would store a file in storage/app/file.txt
Laravel Configuration

ci zip encoding class not working properly

I want to crate a zip file and download it.
So my code is as follow;
Since i am using ci zip encoding class
my folder structure is like
c:/xampp/htdocs/gallery/print/oid_1/1.jpg,2.jpg,3.jpg
My code
$path = getcwd().'/print/oid_1/';
$this->zip->read_dir($path,FALSE);
// Download the file to your desktop. Name it "my_backup.zip"
$this->zip->download('oid_1.zip');
Here is my problem,
l C:\Users\instinctclassic\Downloads\Compressed\oid_1.zip: The archive is either in unknown format or damaged so what does this means -does it means it was mistaken while making zip file or it was mistaken while downloading.For downloading mistake i have downloaded the zip file many time enough to be sure.
2 I repaired the downloaded zip file(oid_1) and extract it but the extracted folder structure is not ignored before the oid_1 folder as said in ci zip encoding class tutorial
$this->zip->read_dir($path, FALSE);
//This will create a ZIP with the folder "directory" inside, then all sub-folders stored correctly inside that, but will not include the folders /path/to/your.
3 Assuming my folder oid_1 already exists somewhere on server.
I know this question is previously asked but mine exist all the problem from making zip file to extracting.So i am sorry for this.
Thanks
Try directory path like this:
$path = getcwd().'\print\oid_1\';
this way path will be proper, because getcwd() will return you c:\xampp\htdocs\gallery

Read XLS to import in MySQL with PHP

I am creating a module that users can upload a '.xls' file and then it must be inserted in MySQL with PHP.Server is free bsd and have all permissions by now.I have tried PHPexcelReader,but it is not working.Can u suggest me something that it can do the work.
p.s.: with phpexcelreader is writing 'The filename xxxxxxx it not readable', but it IS readable and can be downloaded.
The filename is not readable? Is it possible the file was renamed and you are still using the old name?
Well I use PHPExcel and it's available at this link
PHPExcel
You might need to pass the full absolute path to the XLS file, something like this for example:
/var/www/testing.somesite.com/uploads/xxxxxxx.xls
Or just CWD to the directory which contains the file before trying to access it.

Including file in cakephp

I'm getting mad. I can't understand what's the problem.
Obviously i'm trying a require_once() but it doesn't work. As you can see, the file should be in the right place. Anyone have a clue why it doesn't work?
If you have a file in your vendors folder (i.e., vendors/filename.php)
You can do:
App::import('Vendor', 'filename');
Here's some more examples of including vendors
You can include files in different ways:
http://book.cakephp.org/2.0/en/core-utility-libraries/app.html
In your case you're using Lucene as a vendor, so the correct include would be:
App::import('Vendor', 'lucene/Search/Lucene');
to load /app/Vendor/lucene/Search/Lucene.php
Just place your path appropiately. For instance
require_once('/cake/importedfolder/imported_file.php');
In as much as your .htaccess is set to have permission and mod_rewriting is enabled.
To narrate better: you can place the file or folder containing the file you want to import in the 'webroot' folder
For instance we want to require a connection.php file (just to explain tho).
All you have to do is place the file in 'webroot'
And then require it. : thus 'require_once(/cake/connection.php');
Let me know if this helps.....

Categories