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 · 8 comments
Closed

How to use Minify without composer #83

matthiasmullie opened this issue Nov 19, 2015 · 8 comments

Comments

@matthiasmullie
Copy link
Owner

@matthiasmullie 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

@gitrequests gitrequests commented Nov 20, 2015

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

@PaoloFalomo
Copy link

@PaoloFalomo 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 tjespe commented May 30, 2016

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

@matthiasmullie
Copy link
Owner Author

@matthiasmullie matthiasmullie commented Jun 10, 2016

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 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

@matthiasmullie matthiasmullie commented Aug 14, 2017

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 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 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';

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

Successfully merging a pull request may close this issue.

None yet
7 participants