Netbeans PHP Code completion failing me, or am I failing it? - netbeans

First off here is some information, I am using Netbeans 7.0 with the project's php interpreter set to 5.3. The reason for this is I am working with namespaces.
So the setup is thus, I have 3 folders
-app Namespace App
--controller
--model
--view
---*login.php
-system Namespace Sleek
-vendor Namespace Vendor
--*Reform.php
I am using Autoloading, however the entire project is, and this is the first instance I've run into where code completion didn't work, I find it curious...
Reform.php
namespace Vendor;
abstract class Reform {
static function HtmlEncode($str);
}
is being called in...
login.php
(snip)
<input id="url" name="url" type="hidden" value="<?php if (isset($_GET['r'])) { echo \Vendor\Reform::HtmlEncode($_GET['r']); } else { echo "/"; }; ?>">
(snip)
Ignore the horrible view setup with logic inside it please and help me understand why when I type \Vendor\Reform:: netbeans has no suggestions for me, yet it compiles and runs under E_STRICT

It was a bug in netbeans PHP code completion
http://netbeans.org/bugzilla/show_bug.cgi?id=206521

Related

Class 'mPDF' not found in Yii2

I have problem with my page on server.
I'm using yii2 framework and mPDF;
All configured according to the instructions: http://www.bsourcecode.com/yiiframework2/create-pdf-files-using-mpdf-in-yiiframework-2-0/
Page work on localhost on Windows and Xampp
When I try run page on Debian 8 I have error:
Class 'mPDF' not found
Configuration: http://www.bsourcecode.com/yiiframework2/create-pdf-files-using-mpdf-in-yiiframework-2-0/
function in php:
public function actionCreatepdf()
{
$request = Yii::$app->request;
$generate_table = $request->post();
$mpdf = new mPDF;
$mpdf->WriteHTML($this->renderPartial('view_pdf', ['data'=>$data]));
$mpdf->Output('data.pdf', 'D');
exit;
}
I have no idea what I'm doing wrong, it's not running on Debian
I had this issue when migrating from Ubuntu (php 5.6) to CentOS 7 (PHP 7.1)
The easiest thing to do, without manually editing the composer file was to change the use/import in the controller:
//use mPDF; #Php 5.6
use Mpdf\Mpdf; #Php 7.0
Solved! As mentioned before it was due to capital cases.
I used following and it is now working on CENTOS 7 (probably similar on most Linux versions)
<?php
namespace app\controllers;
use Yii;
//use mPDF; Note this line is Commented out
use mpdf;
And then use it as follows:
public function actionIndex(){
$model = new Mpdf();
$model->SetHeader('header');
$model->WriteHTML("PDF contents");
$model->SetFooter('footer');
$model->Output('MyPDF.pdf', 'D');
exit;
}
In my case which i just resolved, adding
'mPDF\' => array($vendorDir . '/mpdf') to autoload_psr4.php required me to namespace most of the class files in ../mpdf/classes using the line
namespace mPDF;
Also among the errors i fixed was changing include to include_once to prevent php from seeing some classes as duplicate declaration despite the presence of class_exists() test

Calabash 1.0.23 throws on xsl-formatter step: ERROR: Failed to instantiate FO provider

I'm trying to use XML Calabash 1.0.23 to run XSLT transformation and FO formatting in a single pipeline. Although the XSLT step works fine, I cannot get the xsl-formatter step to work with FOP.
Every time I run the pipeline, Calabash throws:
ERROR: pipeline.xpl:13:68:Failed to instantiate FO provider
ERROR: Underlying exception: org/apache/fop/apps/FopFactory
My call to Calabash from the command line is:
java com.xmlcalabash.drivers.Main -c cfg.xml myPipeline.xpl
And the cfg.xml configuration file being referred to in the above line is:
<cc:xproc-config xmlns:cc="http://xmlcalabash.com/ns/configuration">
<cc:fo-processor class-name="com.xmlcalabash.util.FoFOP"/>
</cc:xproc-config>
For some reason, Calabash seems to ignore the config file setting, because regardless of the value of the class-name attribute on <cc:fo-processor>, it always throws the same error message. For example, if I use com.xmlcalabash.util.FoAH, the same happens; and if put a nonsensical value, the same occurs. It's always an exception on org/apache/fop/apps/FopFactory.
Just for the sake of completeness, this is my XPL:
<declare-step name="main" version="1.0" xmlns="http://www.w3.org/ns/xproc">
<input port="parameters" kind="parameter" />
<xslt name="transformation">
<input port="source">
<document href="myMarkup.xml" />
</input>
<input port="stylesheet">
<document href="myStylesheet.xsl" />
</input>
</xslt>
<xsl-formatter href="newDoc.pdf" >
<input port="source">
<pipe step="transformation" port="result" />
</input>
</xsl-formatter>
</declare-step>
Of course, if I manually pass the generated FO from the XSLT step to FOP 1.1, it converts it to PDF with no problems. The issue only arises when trying to do the conversion within the pipeline.
I could really use some help to solve this. I'm clueless at this point.
This may seem like a very pedantic reply, but do you have fop.jar (and fop-hyph.jar, which I think FOP requires) on your classpath? They're not bundled in the XML Calabash distribution, you have to get them from Apache.

How to add my own custom class in Laravel 5?

Ok, in laravel 4, if I want to add my own custom class, eg : library\myFunction.php then I do the following steps :
add "myFunctions.php" into app/library/myFunctiosn.php
at app/start/global.php , within ClassLoader::addDirectories(array( , I add app_path().'/library',
And to call it within my blade view, I add the following codes
<?php
$FmyFunctions1 = new myFunctions;
$is_ok1=($FmyFunctions1->is_ok());
?>
The contents of app/library/myFunctions.php is :
<?php namespace App\library {
class myFunctions {
public function is_ok() {
return 'myFunction is OK';
}
}
}
?>
And it works.
But how to do so in Laravel 5 ???
PS : I read What are the best practices and best places for laravel 4 helpers or basic functions?
And tried to add "app/library/", to the autoload array and run composer dum-autoload , but it keeps give me error :
FatalErrorException in xxxx line xx: Class 'myFunctions' not found
I'm also already trying to use :
composer update
composer dump-autoload
php artisan dump
php artisan clear-compiled
php artisan dump-autoload
php artisan optimize
php artisan route:clear
php artisan route:scan
php artisan route:list
But still doesn't work...
This should help you.
FYI:
Basically, you could create another directory within app, and then namespace your files in there as appropriate:
app/CustomStuff/CustomDirectory/SomeClass.php.
Then, within your SomeClass.php, make sure you namespace it:
<?php
namespace App\CustomStuff\CustomDirectory;
class Someclass {}
Now, you can access this class using the namespace within your classes:
use App\CustomStuff\CustomDirectory\SomeClass;
After some trial and error, I found the answer.
There is no need to modify Composer. Just modify the Blade into:
<?php
$FmyFunctions1 = new \App\library\myFunctions;
$is_ok = ($FmyFunctions1->is_ok());
?>

how to configure doctrine command line tools on zenframework 2

i am using doctrine 2 on zendframework 2. i have configured both correcly and they are both working.
i however wish to use doctrine's command line tool to generate entities etc.
i have followed doctrine's instructions and created a cli-config.php page in the root of my application:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html
i am however lost on two issues;
the configuration requires a bootstrap php page; however, zendframework 2 does not use a bootstrap page; so what would the equivalent be?
Secondly, it requires us to obtain an entity mangager; would the method below be the correct way to get the entity manager:
public function getEntityManager()
{
if (null === $this->em) {
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
}
return $this->em;
}
below is how the cli-config.php page should look;
// cli-config.php
require_once 'my_bootstrap.php';
// Any way to access the EntityManager from your application
$em = GetMyEntityManager();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
i would really appreciate any help or advice on this matter.
warm regards
Andreea
the matter has been resolved:!!
it did not work because i was using a cygdrive command line. however, when i switched to git bash it worked perfectly. with git bash i have to use the command:
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
If you have started your project using the Zend Skeleton Application you do have a composer.json file. You just need to include the DoctrineORMModule (instructions here)
Then, using the CMD just type
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
There you go.
Once you have set up doctrine2 and zf2, you should be able to simply run all CLI commands.
php public/index.php orm:generate-entities
Using the parameters as described in the official documentation.
Note: DoctrineModule and DoctrineORMModule need to be enabled within your application.config.php
You need to install the doctrine/doctrine-orm-module with your Composer dependency manager. To do that, cd to your web site's top-level directory and type the following command:
php composer.phar require doctrine/doctrine-orm-module *
After executing this command, the DoctrineModule and DoctrineOrmModule will be installed into your vendor folder, and Doctrine commands will become available.
For more information about DoctrineOrmModule, see this:
https://github.com/doctrine/DoctrineORMModule

The module "taggableComplete" is not enabled

I'm trying to add the tag widget from the plugin sfDoctrineActAsTaggablePlugin
I've added "_tag" to my configuration.yml, and in _tag.php I wrote :
<?php include_component('taggableComplete','tagWidget', array('object' => $form->getObject())) ?>
But all I get now is the following error :
"The module "taggableComplete" is not
enabled"
What am I missing ?
You have to enable modules you want to use after installing a plugin.
tagWidget component is defined in taggableComplete module. As it's a module from the plugin you have explicitly enable it.
You can do it in your application's settings.yml file:
all:
.settings:
enabled_modules: [default, taggableComplete]