Cannot use Zend_Debug::dump in ZF2..how do I? - zend-framework2

I'm using the skeleton application for ZF2.0.0Beta3.
So, normally I would just use Zend_Debug::dump($someVar); however, in ZF2 it doesn't include the zend classes it seems.
The error is: Fatal Error: Class 'Zend_Debug' not found..
This is probably a really basic question, but what's the best way to include that class? Do I have to put require_once('path/to/Debug.php');?

It still exists in ZF2, but since ZF2 started using PHP namespaces, you would now have to call it using the Zend namespace:
\Zend\Debug\Debug::dump($var);
or add a use statement at the beginning of the file and call it like this:
use Zend\Debug\Debug;
Debug::dump($var);

In my case this was the correct namespace-path :
\Zend\Debug\Debug::dump($form);

Additionally, you can get it like this:
use Zend\Debug\Debug;
// ...
Debug::dump($someVar);
Seems like a lot of work just to dump a variable, though. I'm pretty sure in most case I'll just end up using \Zend\Debug\Debug::dump() more often.

You can use it like that:
\Zend\Debug::dump('asd')

Related

How can I add a packge to the reflection support on Graalvm?

Is it possible to add a package in the reflection-config.json?
Something like:
[
{
"name" : "org.apache.tinkerpop.shaded.kryo.serializers.*",
"allDeclaredConstructors" : true
}
}
Instead of doing it one by one.
Thanks :)
As far as I know, that isn't possible yet. There is an open feature request for this: https://github.com/oracle/graal/issues/1236
Probably the best would be to create a Feature class which would register classes for reflection programmatically. Here's a short example: https://www.graalvm.org/reference-manual/native-image/Reflection/#configuration-with-features
The feature class needs to be on classpath then referenced using the --features= command line option.
I am using tracing agent features to auto generate a list for reflection/jni/resources, this should be quite convenient until one day the wildcard features is implemented. (I bet it will not be implemented due to performance concern.)

How to add custom fields in ZFC-user module for zend 2 without doctrine?

I have tried using creating a different module and attaching the ZfcUser\Form\Register over init method. But it wasn't working.
I want to add few custom fields, with changing any thing in the vendor dir, as is it not a good practice. I also tried using user_entity_class ,creating a custom 'User' class, but it was creating some route issue in other modules, with zfc-user , I'm also using zfc-admin and zfc-adminuser, the error was coming in zfc-adminuser, Couldn't found the class was the error.
Thanks in advance.
Well there are some issue regarding the overriding of the module ZFC-User, But still you can overwrite it manually.
One way I have used is a bit old fashioned but working. What I have done is I have copied complete module the to module folder. Then pointing the form towards to my module where the changes are required, rest all are pointed to default.With this you can update your module. Make sure you point the user_entity_class to your module something like this:
'user_entity_class' => 'MyZfcUser\Entity\User',
you can find this in config\autoload\zfcuser.global.php

ZF2 BBCode Parser

Hiho,
I use the ckeditor on my website for special textareas like forum
or signatures.
But I have a problem with the output. I use ZF2 and would like to
use ZendMarkup to render the output bbcode back in html.
But at every time I call
$bbcode->render(...)
I got the error
There is no Zend_Markup_Root markup.
The ZendMarkup is an extension inspired by the Zend_Markup from ZF1.
But I can't find any thing on API or other guides.
Does someone has any idea what as the problem is?
The ZendMarkup library is very old (last update is 10 months ago!) so I wouldn't use such library. If you would like, I think I traced the error down.
On this line there is a reference to Zend_Markup_Root while that should be ZendMarkup\Renderer\Markup\Html\Root. Try to change that line and see what happens.
Another way is to replace the ZendMarkup library with another library which does work and is updated regularly. An example is Decoda. If you load mjohnson/decoda in your composer.json, you can use Decoda in your Zend Framework 2 application:
<?php
use Decoda\Decoda;
$parser = new Decoda($bbcode);
$html = $parser->parse();
With tools like composer, there is no need to use solely Zend* components when there are better alternatives.

Lint for ASP.NET MVC?

Is there a lint utility for ASP.NET MVC? Given that I frequently specify views and links via strings, when I move things around or change entity names I often break things, which I then only find out about when something fails at runtime.
ReSharper's v6 (whose nightlies are now available, if you don't mind living on the edge) will catch this kind of error for you.
You can use Refactor -> Rename and enable Search in Strings to replace every string in the solution
Other option -- use the strongly typed helpers (which might still be in the futures assemblies). EG, Html.Action<ProductsController>(x => x.ShowProduct(id)) ; really the only way to fly.
I don't know that there's something like that, but I'll tell you what I do: All my view names are in a struct that contains string constants. It's a pain to keep it sync'ed as the project changes, but it's worth it because you're far more likely to catch errors if you're using
ViewNames.Customer
rather than
"customer"

How to create/use custom classes and helper in symfony 1.4?

What is the best way to put custom library or helper methods in symfony?
I am using doctrine with my project. One place I consider to put is under project_root/lib/vendor/MyClasses/
But if I want to create a class or helper function which will use some core symfony/doctrine methods and return a result then how to do that and where should I put it?
I want it to call from different modules to avoid code duplication.
As for the custom library part of the question, you might probably want to put your external library into the lib/vendor folder. Since symfony doesn't automatically load everything that's in there, you'll have to tell its autoloader to do so.
You can either extend your config/ProjectConfiguration.class.php (as described here) or (and this is the much simpler and cleaner way) you add them to your config/autoload.yml (you might have to create this one).
For the latter option, this is a great place to start looking at.
It seems to be a duplicate question.
As asked in symfony's 1.2 "Definitive Guide" docs :
Helper functions (regular PHP functions returning HTML code) should be saved in a file called FooBarHelper.php, where FooBar is the name of the helper group. Store the file in the apps/myapp/lib/helper/ directory (or in any helper/ directory created under one of the lib/ folders of your project) so it can be found automatically by the use_helper('FooBar') helper for inclusion.
So, if you want to create custom helper FooBar for foo() function, create file lib/helper/FooBarHelper.php :
function foo() {echo "foo!"; }
to use it in your template:
use_helper('FooBar')
....
foo(); //outs "foo!"

Resources