How do I install mpdf 7 without composer? - mpdf

I'm currently using mpdf 6.1 and I'd like to switch to 7. But I can't find a way to install it without composer. Is there a full package that I can download, unzip and test on my localhost?

well, i've spend few days to search a way, finally i found it, you can download full package mpdf in this site, after download extract files and place on your project and load 'vendor/autoload.php'. in my case i use it with codeigniter, so i make some php file on libraries folder to load it.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class M_pdf
{
function __construct()
{
include_once APPPATH.'libraries\vendor\autoload.php';
}
function pdf()
{
$CI = & get_instance();
log_message('Debug', 'mPDF class is loaded.');
}
function load($param=[])
{
return new \Mpdf\Mpdf($param);
}
}
after that i use it on my controller file :
$this->load->library('M_pdf');
$mpdf = $this->m_pdf->load([
'mode' => 'utf-8',
'format' => 'A4'
]);
$mpdf->WriteHTML("Hello World!");
$mpdf->Output();
but i still recommend to use composer as well,

There is no official v 7.x package including dependencies. To install without composer, you need to do two things:
1) Download the library and all dependencies
For version 7.0.3, that will be
psr/log,
setasign/fpdi (if you need to import other PDF documents),
paragonie/random_compat (if you have PHP 5.6),
myclabs/deep-copy
2) Ensure all needed classes are loaded
This means both mPDF classes and dependencies classes.
You can do this manually (reload, find the file with missing class, add require call, repeat) or you can use some autoloading library.
Or, just use composer, it will do all this work for you in one composer require mpdf/mpdf command and one require vendor/autoload.php call.

Using MPDF without using composer
1.Open your any htdocs folder and make new file of any extension
img-1
Note: Make sure you installed composer into your local server. if not then check this link
composer install
Open that php file into notepad++ file then right click and open folder in cmd.
img-2
3. After open cmd, type: “composer require mpdf/mpdf” then enter
img-3
After done this, you got 3 files in folder
img-4
Make Zip of these 3 files and upload into the server directory with your code
Try with below code
<?php
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<h1>Hello world!</h1>');
$mpdf->Output();
?>
For more details :
mpdf doc

Related

Drupal9: installing problem PHP-encryption library

for encryption data i wants to use in Drupal9 the PHP-encryption library width "REAL AES" Module. But Drupal can not find the PHP-encryption library while enaple the "REAL AES" module.
It is very new to use PHP-encryption in Drupal9, so i think there can be a bug in code or in readme.txt of Installationprozess.
So my main question is: In Which folder do i have to install PHP-encryption-Code?
I installed by the hint of REAME.txt "composer require defuse/php-encryption". But it was unclear in which folder:
In Root of Server? or
In Drupal-Folder sites/all/libraries/php-encryption or
In Drupal-Folder of REal AES Module: modules/real_aes/defuse/
Question: Drupal9 works with composer. Do I have to activate the PHP-encryption library especially? for ex. in main composer.json ?
Thank you for your help, because I m new in Drupal9.
After activating the REAl AEs Module in Drupal9, the module wants to use the library. That does not work, so it shows the errormessage
Please install the Defuse PHP-encryption library via Composer. See README.txt
I use this Drupalmodule:
https://www.drupal.org/project/real_aes
PHP-encryption library:
https://github.com/defuse/php-encryption
So now im looking in the code of php-encryption library und found the Problem in checking the existens of a Class which causes the problem.
so this becomes false instead of true:
if (class_exists('\Defuse\Crypto\Crypto'))
in https://www.drupal.org/files/issues/2613682-3.patch
So the result is the text above "Please install the Defuse PHP-encryption library via Composer"...
but the class Crypto is in folder /defuse/src/Crypto.php
<?php
namespace Defuse\Crypto;
use Defuse\Crypto\Exception as Ex;
class Crypto
{
Now it works:
I had to install php-encryption-library with composer in folder of the module!

How do i locate wordpress plugin directory?

I am trying to add a function from plugin 1(wp job manager) to plugin 2(woocommerce).
I have decided to do this by including the php file from plugin 1, however I am unable to locate the file directory. I have used:
include( plugin_dir_path( __FILE__ ) . 'wp-job-manager/includes/class-wp-job-manager-applications.php');
but it returns the following error:
Warning:
include(/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/wp-job-manager/includes/class-wp-job-manager-applications.php): failed to open stream: No such file or directory in
/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/themes/listify-child/functions.php
on line 77
Please advise me as I've been stuck on this issue for really long... Thanks!!!
Wordpress setups have a constant ABSPATH defined (look at the bottom lines of wp_config.php) which points to the full and absolute path of the Wordpress setup, so in your case echo ABSPATH; would return /home/content/p3pnexwpnas05_data02/78/2394078/html/.
For most installations, appending wp-content/plugins/ to that string would point you to your plugins directory.
However, in a Wordpress configuration one can also customize the wp-content and or plugins directory to their own preference, so building plugins on ABSPATH.'wp-content/plugins/ is not recommended. Unfortunately Wordpress simply doesn't have a get_absolute_pluginspath() function or something available. A trick would be to fetch the plugins-URL, and remove the site-URL from it, so the remaining data is wp-content/plugins/ (or whatever the user has made of it). In code:
$plugins_directory = ABSPATH.str_replace(site_url()."/","",plugins_url())."/";
Which in your case would return:
/home/content/p3pnexwpnas05_data02/78/2394078/html/wp-content/plugins/
You probably mean:
plugin_dir_path(__FILE__)
That gives you the directory path to the file that statement is in. So what that returns depends on where you run it. If you use this statement
include( plugin_dir_path(__FILE__) . 'wp-job-manager/includes/class-wp-job-manager-applications.php');
in the main plugin file for wp_job_manager (probably wp_job_manager.php), then plugin_dir_path(__FILE__) give the path of the directory that file is in (the plugin directory).
If you use it in some other file, you will need to adjust the rest of the path string accordingly.

How to get the current directory within a meteor Smart Package

I am building a package for meteor to be published on Atmosphere and I need to get the current directory that the package is installed. I have tried process.cwd() in a file that's included in the package, but that gets the current directory of my app. The package is installed and working correctly, it just seems that the package is running in the same process as the app, hence process.cwd() is getting the current app dir. Does anyone know of a trick to get the current directory of the package?
This is what I have in the package files:
package.js
Package.on_use(function (api) {
api.use('sync-methods', 'server');
api.add_files(["lib/api_server.js"], "server");
api.add_files(["lib/api_client.js"], "client");
});
api_server.js
var cwd = process.cwd();
console.log(cwd);
This displays /home/dknell/meteor-apps/testApp
Why would you need current directory? To access a file inside the package? Then add a file as n package asset:
api.add_files(['file.txt'], 'server', {isAsset: true});
And then you can read it with Assets.getText('file.txt') in your package.
If you don't want the content, but an absolute path for another tool, you can try
var path = Npm.require('path');
var base = path.resolve('.');
var assetsBase = path.join(base, '/assets/packages/<author_smart-package-name>');
For the <author_smart-package-name> enter your package name, but if it has your meteor user name included, change the colon (:) to underscore (_)
That seems okay on OS X and Linux, probably works in windows as well.
oops, this is for files within the app, not a package. anyway maybe helpful to someone
I need to access a directory path for loading a list of files
// files in /private get built to:
// .meteorlocal/build/programs/server/assets/app/
// base path resolves to:
// .meteor/local/build/programs/server
so you need to manually add "/assets/app" to your paths.
until meteor change this at some point.
just getting to the content of a file isn't helpful if you have a directory of changing content...

Undefined method registerNamespaces() symfony2

I'm following this FOSTwitterBundle documentation:
https://github.com/FriendsOfSymfony/FOSTwitterBundle
I did it all step by step, but when I access my site, i get this error:
Fatal error: Call to undefined method Composer\Autoload\ClassLoader::registerNamespaces() in C:\xampp\htdocs\Symfony\app\autoload.php on line 16
My autoload.php is like this:
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
$loader = require __DIR__.'/../vendor/autoload.php';
// intl
if (!function_exists('intl_get_error_code')) {
require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
$loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
}
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
$loader->registerNamespaces(array(
// ...
'FOS' => __DIR__.'/../vendor/bundles',
// ...
));
return $loader;
What should I do?
for symfony 2.*
replace this
$loader->add('FOS' => __DIR__.'/../vendor/bundles');
with
$loader->add('FOS', __DIR__.'/../vendor/bundles');
The basic problem is that the installation directions are for Symfony 2.0. You are using S2.1. I have not poked around in the twitter bundle. Hard to say if it will even run under 2.1. Installing it via git submodule instead of using composer seems strange.
Try starting over and adding: "friendsofsymfony/twitter-bundle": "dev-master" to your composer.json and doing an install. This should bring down the packages and take care of autoloading for you.
Otherwise, replace:
$loader->registerNamespaces(array('FOS' => __DIR__.'/../vendor/bundles'));
with
$loader->add('FOS' => __DIR__.'/../vendor/bundles');
S2.1 uses a different class loader than S2.0 with a different interface. It will at least get you past the error message.
But again, try the composer route first and then maybe submit a patch to the project to update the readme file.
OAuth?
I used https://github.com/hwi/HWIOAuthBundle no long time ago.
How to integrate with FOSUB: https://github.com/hwi/HWIOAuthBundle/issues/81

How to install a Symfony 2.0 Bundle from Zip file

I tried installing the FixturesBundle as described in http://symfony.com/doc/2.0/bundles/DoctrineFixturesBundle/index.html but my proxy wont let me out.
So I went to https://github.com/doctrine/data-fixtures and download a zip from the latest commit.
I unzipped into the vendor directory and renamed it to doctrine-fixures. I edited the autoload.php and AppKernel.php files as described in the tutorial.
When I run:
php app\console doctrine:fixtures:load
I get the following message:
PHP Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesB
undle' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on
line 20
Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle
' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on line
20
Is there a way to run the installation of bundle pointing it to a zip file?
I´m running Symfony 2.0.9 on Windows 7.
Seems like the doctrine bundle has been moved outside of Symfony scope back to Doctrine.
Please, use https://github.com/doctrine/DoctrineFixturesBundle
I had the same problem and this is how i successfully solved it. I started to download this files data-fixtures and DoctrineFixturesBundle, unzipped both into /vendor/doctrine and created this folder structure:
vendor
- doctrine
- doctrine-fixtures-bundle
- Doctrine
- Bundle
- FixturesBundle
DoctrineFixturesBundle.php
..other files...
vendor
- doctrine
- data-fixtures
- lib
- test
composer.json
..other files...
Then i edited the AppKernel.php and added
public function registerBundles(){
.....
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
.....
}
Edited the composer.json located in the root of the project and added this 2 lines:
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
Mine, now look like this:
{
"autoload": {
"psr-0": {
"": "src/",
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
}
}
}
afterwards execute composer dump-autoload -o to recreate the classmap. All this was thanks to the users Wouter J and nifr that answered my question How to install DoctrineFixturesBundle offline
Happy coding!
Yes, it's true that Doctrine is being moved away from the Symfony namespace (see here).
So if you're using the Symfony standard distribution you download from the website (without using git), and you want to have the FixturesBundle installed manually, you have to download the doctrine-fixtures library from here, extract the zip into
YourProject/vendor/doctrine-fixtures
Download the FixturesBundle from here, and extract it in
YourProject/vendor/bundles/Doctrine/Bundle/FixturesBundle
Then you have to register the library's namespace, do it by adding
'Doctrine\\\\Common\\\\DataFixtures' => \__DIR\__.'/../vendor/doctrine-fixtures/lib',
in your autoload.php.
In addition, you'll have to register the Doctrine's namespace, because some part of your application will be using the DoctrineBundle shipped from the Symfony namespace, but the new downloaded FixturesBundle will be using the new Doctrine's namespace, so to make it work, in your autoload.php add the following line (taking care you do it before the Doctrine namespace, remember that more specific rules go first!)
'Doctrine\\\\Bundle' => \__DIR\__.'/../vendor/bundles',
So all you have to do now is to register the new bundle in your AppKernel.php writing
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

Resources