Adding Symfony Yaml To Silex - symfony1

I am looking to add symfony's yaml component to Silex however I am having issues with adding the 5.3 version. Adding the none namespaced version works fine but I would rather have the namespaced version from https://github.com/symfony/Yaml. This is my service provider:
public function register(Application $app)
{
if (isset($app['classPath'])) {
$app['autoloader']->registerNamespace('Symfony\Component\Yaml', $app['classPath']);
}
}
But when I do this is code:
use Symfony\Component\Yaml\Yaml;
Yaml::load(__DIR__ . '/../configuration/application.yml');
I receive the error of:
Fatal error: Class 'Symfony\Component\Yaml\Yaml' not found in
/mnt/hgfs/silex/web/index.php on line 20
Full Correct Answer:
gregoire made a comment about registering the Symfony namespace, not the Symfony\Comonent\Yaml so I basically recreated the directory structure for the namespace and registed the root of the to the Symfony namespace and that works great.

Now that silex is using composer, I am just using composer to include it.

Related

TYPO3 dependency injection with mpdf/mpdf

I'm currently upgrading a TYPO3 extension from v9 to v10 which uses mpdf/mpdf.
In Services.yaml I've added
mPDF\:
resource: '../../../../../vendor/mpdf/mpdf/'
But now I end up with this error message:
Expected to find class "mPDF\MpdfException" in file
"/var/www/xxxx/vendor/mpdf/mpdf/MpdfException.php" while importing
services from resource "../../../../../vendor/mpdf/mpdf/*", but it was
not found! Check the namespace prefix used with the resource.
The problem is, that the class is MpdfException and not mPDF\MpdfException.
I tried to add
MpdfException\:
resource: '../../../../../vendor/mpdf/mpdf/'
This didn't work.
Next I tried to add this to the global composer.json:
"autoload": {
"psr-4": { "mPDF\\": "vendor/mpdf/mpdf/" }
}
but that didn't work either.
Many thanks for your effort to help me, Julian! Much appreciated! It turned out that the extension had a requirement for an outdated version of mPDF. After using the latest version of mPDF it now works. Nevertheless I still need Services.yaml.

"NestModule" , "NestMiddleware", "MiddlewareConsumer" has no exported member in types/#nestjs/common

I am new to NestJs and tried implementing the middleware specified in NestJs documentation,
https://docs.nestjs.com/middleware
When NestMiddleware is imported i am getting the following error
" Module '"../../types/#nestjs/common"' has no exported member 'NestMiddleware'". and similar errors while importing "NestModule" and "MiddlewareConsumer'.
Iam using nestJs version 6.0.0
NestModule, MiddlewareConsumer, and NestMiddleware are all imported from #nestjs/common. From your project root, that would be <root>/node_modules/#nestjs/common/index. If you are having trouble importing these sources, you may need to re-install your dependencies.

Angular 4+ 3rd party module import 404 error with base tag

I am putting an angular portion into my MVC app. As such, I have added a tag to my layout view to find the Angular source code, and this is working great.
My issue arises in trying to add a 3rd party module to my project. I added it through the package.json with no problem, and added the module to my app.module.ts as follows:
import { FileUploadModule } from 'primeng/fileupload';
The reference is found, Visual Studio is happy, everything is fine. However, when I run the project locally, I get the following 404 error:
GET http://localhost:59911/src/primeng/fileupload 404 (Not Found)
It seems to me likely that the tag is causing the issue, but I can't remove it without killing the rest of the Angular functionality. Any hints? Can I add an override to the imports call?
Thanks, Mike
On PrimeNG's official website they suggested using import { FileUploadModule } from 'primeng/fileupload'; but it doesn't work any more. I guess they didn't update the docs.
You need { FileUploadModule } from 'primeng/primeng';
The structure is
In the primeng.d.ts file PrimeNG re-exported all modules.
export * from './components/fileupload/fileupload';
For now, no matter which PrimeNG module is used, it is all from primeng/primeng. Here's the imported modules in my project:
import {
ButtonModule,
CodeHighlighterModule,
ConfirmDialogModule,
FieldsetModule,
FileUploadModule,
GrowlModule,
MessagesModule
} from 'primeng/primeng';
The version I use is "primeng": "^4.2.1"
The issue was that primeng was not in the mapping, so it was looking for it in src.
I added the following to systemjs.config.js:
in maps:
'primeng': 'npm:primeng',
in packages:
primeng: {
defaultExtension: 'js'
}
Thanks for the help everyone!

No Relationship class found in neo4jphp when using neo4jphp.phar

When running neo4jphp/neo4jphp.phar on a local machine, seems that Noe4j - 1.9.RC2 works correctly. Also, the web interface is available.
When runnning the command (below)
$arthurOutgoingRelationships = $arthur->getRelationships(array(), Relationship::DirectionOut);
, I am having
PHP Fatal error: Class 'Relationship' not found in /var/www/index.php
in the Apache error log. I downloaded the latest available version of neo4jphp as well as registered the autoloader:
spl_autoload_register(function ($className) {
$libPath = '/var/www/neo4jphp/lib/';
$classFile = str_replace('\\',DIRECTORY_SEPARATOR,$className).'.php';
$classPath = $libPath.$classFile;
if (file_exists($classPath)) {
require($classPath);
}
});
You can work around this by downloading the library from GitHub, copy the Everyman folder with its subfolders in your root directory and use what you need. In example
require("phar://neo4jphp.phar");
use Everyman\Neo4j\Relationship;

symfony: How to fix auto-generated static file path?

I'm trying to create an app with symfony ver.1.4.11.
I created a symbolic link to the path of "web" directory.
$ ln -s /path/to/myprojectroot/web/ ~/public_html/subdir/
So my frontend app is available like the following URL:
http://mydomain.com/subdir/frontend_dev.php
And static files are also visible by inputting the following URL directly:
http://mydomain.com/subdir/images/someimage.jpg
I think this is OK.
But when I call image_tag('someimage.jpg') in template PHP files, the image path will be generated like the following and it will cause 404 Error:
http://mydomain.com/images/someimage.jpg
The image URLs of default top page are also generated like this:
http://mydomain.com/sf/sf_default/images/sfTLogo.png
not
http://mydomain.com/subdir/sf/sf_default/images/sfTLogo.png
Also the URLs by link_to() function cause the same problems.
How can I fix this?
You have to tell symfony what is the directory structure.
You can follow this documentation page.
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
// ...
$this->setWebDir($this->getRootDir().'/web/subdir');
}
}

Resources