Symfony 2 : Handle COM Object - com

I would like to use a COM object in my Symfony 2 Controller. COM must be a part of PHP 5, so I guessed there would have been no problem.
Here is my code:
$ObjectFactory = new COM("CrystalReports11.ObjectFactory.1");
And Symfony returns me this error:
Class 'App\InterfaceBundle\Controller\COM' not found
I'm on Windows 7, using PHP 5.3. When displaying phpinfo, I can see COM object support enabled.
What am I doing wrong? Is there any PHP inclusion to make in the Controller to make it work?

You're working in a namespace called App\InterfaceBundle\Controller, so PHP is looking for the class COM within that namespace.
Changing your code to the following will explicitly tell PHP to load the class from the "global space" rather than the current namespace:
$ObjectFactory = new \COM("CrystalReports11.ObjectFactory.1");
You can read more about namespaces in the PHP manual: http://www.php.net/manual/en/language.namespaces.php

Related

Laravel - Imagick not found when a job calls it

When I call a class from a controller that uses Imagick it works just fine.
When I call the same class from a job it cannot find Imagick
using
$image = new \Imagick();
So not a namespace issue.
Any thoughts most welcome.
EDIT:
So this is a Mac/MAMP specific issue. Works on my production server so I am not so concerned. Both have Imagick extension installed. I suspect artisan listen is making php calls using the system version of php. I did check:phpversion() in my script and it is php 7.020 for both the controller and the job that has the issue. I can live with the mystery :)
Laravel Don't have own Imagick Class u can't use it be default if you have own class add on app/config.php aliases if you don't have i suggest use http://image.intervention.io/getting_started/installation for image convert or crop or anything u like

"Type 'System.Data.SqlClient.SqlConnection' is not defined." in .Net Web Site

I'm trying to get a .NET web site running on a network server, and while everything is set up and running locally on my machine (using IISExpress), when I deploy to a Windows Server 2008 server with IIS installed, I end up getting compilation errors when trying to use an SqlConnection:
Compiler Error Message: BC30002: Type 'System.Data.SqlClient.SqlConnection' is not defined.
Now, I have both import statements at the beginning of the source file as follows:
Imports System.Data.SqlClient
Imports System.Data
In the compilation warnings it lists a very strange error:
Warning: BC40056: Namespace or type specified in the Imports 'System.Data.SqlClient' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases.
Evidently, the compiler can't find System.Data.SqlClient. The IIS application pool is running .NET 2.0, and my site is targeting 3.5. I'm very new to .NET development, and I'm learning this as I go, but this has me stuck. Am I missing a dependency? Do I need SQL Server Management Studio installed on the server?
A couple of things
Inside your web application you might be missing the reference to System.Data
Right click on Solution Explorer
Add References
Click on .NET and find System.Data.dll
You may already have a class called SqlConnection (Your own), and there might be an ambiguity. Reference the Sqlclient/SqlConnection class directly System.Data.SqlClient.SqlConnection
I had this problem.
It's easy to solve it.
REPALCE
using Microsoft.Data.SqlClient;
instead of
using System.Data.SqlClient;

how to invoke a play application without hitting the URL (http request)?

I'm using play application (using Play version 2.1.0) with RabbitMQ and do not have any view component.
So i would like to invoke this play application without hitting the execution URL (http://localhost:9000/<routing_info>) on server startup.
Would also like to know if there is any way in Play 2.1.0 version to run the application on server startup, i mean bootstrapping. Is this option available in play 2.1.0.
As i've read through the documentation its mentioned only for 1.2 version.
Please help!!
Play allows you to define a 'global' object which will be instantiated automatically by Play when the application starts.
In application.conf you should find the following:
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
application.global=global.Global
On a new play application, this line is commented out. I've uncommented it and made it point to an object called Global in the global package. You can make it what ever you want.
Your global object should extend GlobalSettings.
In my applications, I use a static initialiser block to run code when that class is loaded:
public class Global extends GlobalSettings
{
static
{
...
}
}

ZF2 Doctrine ORM console application - error with execution as phar archive

I wrote simply ZF2 console based application. There is source: https://github.com/vagovszky/console. App is designed for import courses from XML into database. Everything works fine until app is packed into phar.
If I pack this application into phar archive (as described in README.md) and execute it, error occured:
Doctrine\ORM\Mapping\MappingException Class "Database\Entity\Ligues" is not a valid entity or mapped super class.
I do not know how fix this issue, thanks for help.
This is a known issue: Doctrine's AnnotationReader isn't able to read annotations from classes within a PHAR package.

Reflexil deobfustication error

I'm trying to modify a .net application and I'm new to this. First step is attempting to deobfuscate the code using reflexil and I get the following error:
Reflexil is unable to clean this assembly: Member 'System.RuntimeTypeHandle "bunch of obfustatcated jibberish"(System.Int32)' is declared in another module and needs to be imported
The application comes with a bunch of dll's that it certainly uses, so I assume the declaration is in one of those files. How do I import this module?
In case it's helpful, reflexil says it was obfuscated with .NET Reactor 4.1
I decided to try de4not to deobfuscate and it worked without this issue.