In one of my previous work I had used a custom library named "OOP"
It was working fine then.
But after a year may be. when I run it again there is these lines are not working---
<pre>
$data['board'] = OOP::selectOptionList(OOP::getBoard());
$data['guardiansRelation'] = OOP::selectOptionList(OOP::guardiansRelation());
</pre>
I think My OOP Library aren't working somehow. is thery any problem with my php version?I am using <pre>PHP version: 5.6.15<br>Apache: 2.4.17</pre>
Related
Everything was fine in my localhost. But after putting in online server I am facing many errors. I got this error and there is not case sensitivity issue in name.
Here is my class name in app->http->view/component
class dashboardHeader extends Component
And here is my calling tag of component in view file.
<x-dashboardHeader />
I also tried this way
<x-dashboardHeader> </x-dashboardHeader>
But still it is not working!
I will put this as an answer since it's too big for the comment.
When you put x-dashboardHeader tag in your template - Laravel is actually trying to load your DashboardHeader class (notice the uppercase D) from the View\Components namespace (read it as LARAVEL_ROOT\App\View\Components\DashboardHeader.php).
It does it using the autoloader which is generated by the composer.
While developing using Windows/MacOS - case sensitivity for the file name isn't a problem, since in those systems you can't have two files with the same name (independent of the name casing). So if you have a file named "myCoolFile" - you can access it using "mycoolfile", "MyCoolFile", etc....
But this isn't the case for unix systems. In those systems file names are case-sensitive. You can have 3 files named "myCoolFile", "mycoolFile", "MyCoolFile" and this won't be a problem. You can test it yourself using:
touch myCoolFile
touch MyCoolFile
touch mycoolfile
ls -l
So going back to Laravel trying to load your LARAVEL_ROOT\App\View\Components\DashboardHeader.php file, the file is named differently in your case dashboardHeader.php. And since DashboardHeader.php and dashboardHeader.php are different files in unix systems - you get the error.
I really hope that I could describe the problem.
This is why I suggest that you might want to read the PHP-PSR docs (which, again, Laravel follows) where it says that classes MUST be named using StudlyCaps. So no "dashboardHeader", no "dashboard_Header" and stuff like that, only "DashboardHeader", "MyCoolClass" and so on.
Installed crabbley/fpdf-laravel as per instructions. Tried some sample code as follows:
$pdf= app('FPDF');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Swordsmen Class Times');
$pdf->Output();
While the instantiation of fpdf is different from the samples in the tutorials, all works as expected and the pdf is displayed in the browser. I got this working sample from the crabbley packagist.org/packages/crabbly/fpdf-laravel readme under 'usage'. The 'usage' instructions also provide an alternative instantiation viz: $pdf = new Crabbly\FPDF\FPDF;
The tutorial samples use something slightly different again, ie
require('fpdf.php');
x=new FPDF();
and thus are a little different. When I changed it to be the same as the tutorial, all I changed was the instantiation line from
$pdf= app('FPDF');
to
$pdf = new FPDF('L', 'mm','A4');
and I get the error 'Class 'App\Http\Controllers\FPDF' not found'. I do not understand the difference between the different forms of instantiation and not sure what is going on but I need the latter format so I can set page orientation etc. I also tried the usage format as described above with the same sort of error, ie new Crabbly\FPDF\FPDF not found.
I have tried the require statement but FPDF is not found and I am unsure where to point 'require' to.
Installation consisted of:
composer require crabbly/fpdf-laravel
add Crabbly\FPDF\FpdfServiceProvider::class to config/app.php in the providers section
Any suggestions will be appreciated.
You are using an implementation for the Laravel framework that binds an instance of FPDF to the service container. Using app('FPDF') returns you a new instance of FPDF, which is pretty much the same what new FPDF() would do.
The require way of using it is framework agnostic and would be the way to use FPDF if you are just using a plain PHP script. While you could use this way with Laravel too, why would you want to do that?
The reason the require does not work, by the way, is that the fpdf.php file is not found from where you call it. It would be required to sit in the same directory unless you give it a path. Considering you installed it using composer, the fpdf.php script, if any, should sit inside the vendor directory.
However, just go with using the service container. The line $pdf = new FPDF('L', 'mm','A4'); just creates a new instance of the FPDF class and initializes it by passing arguments to the constructor, these being 'L' for landscape orientation, 'mm' for the measurement unit, and 'A4' for the page size. Without knowing the package you use and having testing it, you should also be able to set them equivalently by calling:
$pdf = app('FPDF', ['L', 'mm', 'A4']);
Hope that helps!
I'm using PHPWord (https://github.com/PHPOffice/PHPWord) to generate a Microsoft Word file (.docx) which I save to my system. This works perfectly and as expected. I also want to save an Adobe Acrobat version of that file (.pdf) to my system. For that I'm relying on PHPWord in conjunction with dompdf (https://github.com/dompdf/dompdf). That's where the trouble begins.
My PHP code is the following:
// first, save the completed .docx file that I've generated
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "Word2007");
$objWriter->save($path_docx);
// second, set PHPWord PDF rendering variables
\PhpOffice\PhpWord\Settings::setPdfRendererPath("/var/www/html/vendor/dompdf/dompdf");
\PhpOffice\PhpWord\Settings::setPdfRendererName("DomPDF");
// third, load the .docx file which we just saved above
$phpWord = \PhpOffice\PhpWord\IOFactory::load($path_docx);
// fourth, save the new PDF file to the location of choice
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "PDF");
$xmlWriter->save("/var/www/html/export/my-pdf-version-of-the-file.pdf");
When I run the code above I get the following error:
Fatal error: Uncaught exception 'PhpOffice\PhpWord\Exception\Exception' with message 'Unable to load PDF Rendering library' in /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php:94 Stack trace: #0 /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF.php(65): PhpOffice\PhpWord\Writer\PDF\AbstractRenderer->__construct(Object(PhpOffice\PhpWord\PhpWord)) #1 /var/www/html/vendor/phpoffice/phpword/src/PhpWord/IOFactory.php(44): PhpOffice\PhpWord\Writer\PDF->__construct(Object(PhpOffice\PhpWord\PhpWord)) #2 /var/www/html/assets/core/phpword.php(593): PhpOffice\PhpWord\IOFactory::createWriter(Object(PhpOffice\PhpWord\PhpWord), 'PDF') #3 /var/www/html/export/index.php(94): exportOutline(Array) #4 {main} thrown in /var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php on line 94
I began searching Google for errors similar to this and came upon this Stack Overflow post: PHPWord to PDF not able to load library. They suggested editing some code within the "/var/www/html/vendor/phpoffice/phpword/src/PhpWord/Writer/PDF/AbstractRenderer.php" file. The code snippet referenced in that post is the following:
public function __construct(PhpWord $phpWord)
{
parent::__construct($phpWord);
$includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile;
if (file_exists($includeFile)) {
/** #noinspection PhpIncludeInspection Dynamic includes */
require_once $includeFile;
} else {
debug($includeFile);
// #codeCoverageIgnoreStart
// Can't find any test case. Uncomment when found.
throw new Exception('Unable to load PDF Rendering library');
// #codeCoverageIgnoreEnd
}
}
They suggested I get rid of this portion of the code which appears on the 4th line above:
. '/' . $this->includeFile
When I implemented that solution, however, it didn't fix my problem. Frustrated, I then looked at the value generated for $includeFile within that snippet of code. For me, the value was "/var/www/html/vendor/dompdf/dompdf/dompdf_config.inc.php". Once I saw that it was trying to include a file called "dompdf_config.inc.php" I then searched my directory for the file. It wasn't at the referenced location nor anywhere in my system!
At that point I began searching Google again for that file name and ended up on this Stack Overflow post: I Can't Find dompdf_config.inc.php or dompdf_config.custom.inc.php for setting "DOMPDF_UNICODE_ENABLED" true. That post suggests that dompdf 0.7.0 no longer relies on that configuration file. At this point I begin thinking that PHPWord's current version (which I'm using) which relies on dompdf has not been updated to support the current version of dompdf (which I'm using). I simply don't know.
My questions:
Can someone confirm if it's true that PHPWord's current version does not play well with dompdf's current version?
If the current version of both are supposed to work together, then what am I doing wrong and how do I fix it?
Thank you in advance for all of your help!
Note: I should note that I've included PHPWord and dompdf in my project via composer; so all relevant files are located in "/var/www/html/vendor" as one would expect. Also, I can't rely on TCPDF nor MPDF (which are alternate PDF rendering engines) because they generate files that don't meet the formatting needs I require for my project.
I'm trying to use iChemLabs cloud services from a html5 web worker. Normally the cloudservices requires jQuery but I can't import that into a web worker so I'm using Pollen instead with a ChemDoodle Web Components library with which I have stripped out the document-related things.
jQuery.Hive.Pollen provides a nice ajax function very similar to jQuery, but I can't seem to get it to work at all. I know this problem will be tricky to solve considering that Access-control-headers need to be set to allow any of you to actually find the solution. However, I'm a beginning javascript programmer and I was wondering if my two weeks of frustration is actually a small difference. I am trying to invoke the following function:
var cloudmolecule;
ChemDoodle.iChemLabs.readSMILES('N1(C)C(=O)N(C)C(C(=C1N1)N(C=1)C)=O', function(mol){
cloudmolecule = mol;
});
Here is a link to the library code I am using, see the 'q.ajax' call and substitute jQuery = q for p = q (p is for pollen) in that block of code.
Right now I'm just trying to get the ajax call to work in an ordinary block of javascript with the plan to migrate to a web worker later.
If anybody could point out the problem to me I would be extremely grateful.
solved! turns out iChemLabs rejects these two extra headers that pollen creates:
_xhr.setRequestHeader("X-Requested-With", "Worker-XMLHttpRequest");
_xhr.setRequestHeader("X-Worker-Hive", "Pollen-JS" );
Simply comment them out
Also, Pollen ajax seems to return a JSON object containing the data in JSON format AND as a string, so do
o = JSON.parse(data.string)//data is the parameter to the callback function
The reduced ChemDoodle library (without document-related methods) will work like a charm with pollen ajax.
Titanium SDK version: 1.6.
iPhone SDK version: 4.2
I am trying out the cache snippet found on the Appcelerator forum but I get an error: [ERROR] Script Error = Can't find variable: utils at cache.js (line 9).
I put this one (http://pastie.org/1541768) in a file called cache.js and implemented the code from this one (http://pastie.org/pastes/1541787) in the calling script, but I get the error.
What is wrong? I copied the code exactly.
Your problems is whilst the first pastie defines utils.httpcache. The variable utils is not defined outside of this function closure (because it is not defined anywhere in global namespace). As below shows.
(function() {
utils.httpcache = {
};
})();
To make it all work in this instance add the following code to the top of your cache.js file.
var utils = {};
This declares the utils variable in global namespace. Then when the function closure is executed below it will add utils.httpcache to the utils object.
The problem is actually not specific to Appcelerator and is just a simple JavaScript bug. Checkout Douglas Crockfords book, JavaScript the Good Parts. Reading it will literally make you a more awesome JavaScript developer.
You can't use utils.httpcache.getFromCache(url) until you add this to your code:
var utils = {};
That's because how the author created his function, it's called JavaScript module pattern and it's generally used to structure the code.
I seem to lose this value "value.httpCacheExpire = expireTime;" when the code does the "Titanium.App.Properties.setString(key,JSON.stringify(value));" so when I get it back using the getString method, there's no longer the "value.httpCacheExpire.
Anyone else have this issue? Am I missing something to get this working?