Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Minify without composer #83

Closed
matthiasmullie opened this issue Nov 19, 2015 · 9 comments
Closed

How to use Minify without composer #83

matthiasmullie opened this issue Nov 19, 2015 · 9 comments

Comments

@matthiasmullie
Copy link
Owner

matthiasmullie commented Nov 19, 2015

1: Clone this (minifier) repository: https://github.com/matthiasmullie/minify. Make sure you leave the directory structure intact (the files in data/js should stay in the same location relative to src/JS.php)

2: Clone path-converter repository: https://github.com/matthiasmullie/path-converter

3: Include all files from both projects.
Assuming you cloned both projects to /path/to/libraries/, that would look like this:

// make sure to update the path to where you cloned the projects to!
$path = '/path/to/libraries';
require_once $path . '/minify/src/Minify.php';
require_once $path . '/minify/src/CSS.php';
require_once $path . '/minify/src/JS.php';
require_once $path . '/minify/src/Exception.php';
require_once $path . '/minify/src/Exceptions/BasicException.php';
require_once $path . '/minify/src/Exceptions/FileImportException.php';
require_once $path . '/minify/src/Exceptions/IOException.php';
require_once $path . '/path-converter/src/ConverterInterface.php';
require_once $path . '/path-converter/src/Converter.php';

4: Use minifier! E.g.:

use MatthiasMullie\Minify;
$minifier = new Minify\CSS('body { color: red; }');
echo $minifier->minify();
@gitrequests
Copy link

Thanks It works.
But how to use short links here?
For example: domain.com/min/?f=... in link tag?

@PaoloFalomo
Copy link

PaoloFalomo commented May 12, 2016

⚠️ over here. If you use clone it will add /tests/ folders too. And it's not necessary to upload them. Could you please give us a non-composer-needed blob?

@tjespe
Copy link

tjespe commented May 30, 2016

Is the path-converter library really necessary? What does it do?

@matthiasmullie
Copy link
Owner Author

Yes it is. It will convert relative paths in your CSS files if the location of the minified files is different from the source file. It also fixes relative paths inside @imported files, when their content is included in the main minified code.

@jfoclpf
Copy link

jfoclpf commented Aug 13, 2017

Do you need to include the CSS.php if you just want to minify JS? Is there any means to make it lighter for some purposes?

@matthiasmullie
Copy link
Owner Author

If you're only minifying JS, you don't need to include CSS.php. And the other way around.
And if really needed: as long as the code doesn't have to thrown any exceptions, you could also not include those exception files.

@AubinMahe
Copy link

AubinMahe commented Sep 25, 2018

I have this error, why?

Call to undefined function MatthiasMullie\PathConverter\mb_substr()

Response : sudo apt install php7.2-mbstring

@reardestani
Copy link

reardestani commented Nov 8, 2018

we can also use this site: https://php-download.com/package/matthiasmullie/minify

Then we can simply require one file sth like: require_once $path . '/vendor/autoload.php';

@nileio
Copy link

nileio commented Jun 7, 2021

@matthiasmullie thanks for the library .. if i only use it to minify CSS, do I need to include data/js directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants