I want to use my PHPExcel Laravel application. I installed the library in the vendor directory. What is the method to call my controller and thereby implement this example: http://g-ernaelsten.developpez.com/tutoriels/excel2007/?page=fondements#L2.1
In the posts I read it just had to write to the header
use PHPExcel;
use PHPExcel_IOFactory;
It's not sufficient
Who can help me start with this library? and integrate it into my project Laravel. Thank
Maatwebsite made a built a Laravel package for PHPExcel. You can find it here https://github.com/Maatwebsite/Laravel-Excel together with the documentation for it.
If for any reasons you prefer to not use this, you need to
include '/vendor/PHPExcel/PHPExcel';
include '/vendor/PHPExcel/PHPExcel/Writer/Excel5.php';
Related
I wanted to use nusoap_client class so decided to add nusoap library to my laravel project. Like other libraries, i used github readme page to get it done.
composer require econea/nusoap:^0.9.6
This library was added to ../vendor/econea/nusoap/src/nusoap.php. Then i wanted to use it in my controller but i tried many ways to use it like below :
use SoapClient;
use vendor\econea\nusoap\src\nusoap.php;
use nusoap.php;
use nusoap;
I even tried to load library in autoload in composer.json file without any luck. laravel kept repeating same error.
Class 'App\Http\Controllers\nusoap_client' not found
I appreciate any help given that suggests a way to use nusoap_client in my code or the correct way to use the library in my laravel project.
thanks.
my code:
$client = new nusoap_client('example.com/api/v1', 'wsdl');
The proper syntax at the top of your controller should be:
use nusoap_client;
This is happening because this class does not contain a valid namespace.
So, you need to import this PHP file into your script using the require function.
To solve this in laravel, just import your file using composer like:
"autoload": {
"files": ["path/to/vendor/script"]
}
With autoloaded file, you can instantiate the class in any script class of your project.
But, I don't think that's a good way to work with modern PHP.
I know another library that works with SOAP: https://github.com/artisaninweb/laravel-soap
It's a wrapper for SoapClient http://php.net/manual/pt_BR/class.soapclient.php, a PHP core class that provides a soap client.
Hope my contribution can be useful and my english understandable.
I am working with an existing controller in symfony and need to use an api that I have in my vendors directory. Needless to say I am entering a pre-existent, large scale project and with minimum experience in symfony I am not too sure of how to use the vendor directory. When I have tried using "use vendor\fullcontact\sdk*********;" symfony tells me that there is no class called this in my bundle. I have looked for information on using the vendor directory but have came up dry. Any information regarding how I can start using my vendor directory would be appreciated.
Seems you are using the PHP Library for FullContact API.
This library don't use namespace so you can simply try to use it adding an initial slash to the class when you are using it. As Example:
$this->name = new \Services_FullContact_Name($apikey);
Hope this help
PHPExcel is a library to generate MS Excel file using PHP (and so far the best one I have used in supporting Chinese output). It works fine in Laravel. However, unlike libraries for generating email or PDF files, in PHPExcel (and many other libraries used for generating Excel file) the file can only be generated by calling PHP functions instead of converting HTML into Excel, so the code has to be put in controller / classes.
I feel a little uncomfortable to put codes that mainly for views into controller, and it is a group project so readability is also a concern. Is there a way I can put the code generating Excel file into view in Laravel?
You have to install "maatwebsite/excel" package, and then you can use the functionality of PHPExcel. Go: here to get basic information regarding package installation, and here to get detail tutorial, on how to use this package.
See, if that helps.
Laravel 5 allows you to place your classes anywhere in the app folder, given the appropriate PSR-4 compliance.
Therefore, you can create a class which is solely responsible for containing all codes pertaining to the creation of your Excel files.
Then you can call the method, from your controller whenever appropriate.
I tried like
$this->obj->load->library('phpmailer');
$this->obj->load->library('phpmailer/class.phpmailer');
But it causes php error.Please suggest a solution.
create a custom loader for the same. You can find how to extend database classes in codeigniter tutorials on the github site of codeigniter, from that tutorial you can get a hint of whats going on and then you can implement how to create custom library loader well if not you can use "core" folder, it is the autoloader for the libraries. check the documentation for codeigniter.
Check these links:
Extending db drivers
Core classes
Go to the phpmailer library and put this instruction
include('phpmailer/class.phpmailer.php');
Your phpmailer and folder phpmailer should reside in the library folder.Your phpmailer folder should contain the file class.phpmailer.php. Now call it
$this->load->library('phpmailer ');
Done!
I want to add some more library and helpers file into Pyrocms which is based on codeigniter.Actually i have to add facebook connect and found some good working examples of facebook connect so now i want to implement these codeingiter libraries and other files in Pyrocms.Let let me know where to put these libraries. Your help will be appreciable.
since version 1.3.0 addons/default/libraries
or addons/shared_addons/libraries for the pro version. (This bit will help on the where to put stuff topic...
http://www.pyrocms.com/docs/1.3/manuals/developers/understanding-the-addons-directory )
Then load the lib in your controller, etc as such $this->load->library('cool_facebook_connect_lib');
And, depending on your version you may have to change around a couple lines in MY_loader for it to work, http://www.pyrocms.com/forums/topics/view/18087