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

Doesnt work with composer autoload #20

Closed
dzpt opened this issue Dec 26, 2016 · 18 comments
Closed

Doesnt work with composer autoload #20

dzpt opened this issue Dec 26, 2016 · 18 comments

Comments

@dzpt
Copy link

dzpt commented Dec 26, 2016

Getting this error:

Fatal error: Uncaught exception 'LogicException' with message 'Passed array does not specify an existing static method (class 'ComposerAutoloaderInit6abcfcd8de4a38fce2851d378ca1a6d0' not found)' in /var/www/domain/web/library/vendor/composer/autoload_real.php:8
Stack trace:
#0 /var/www/domain/web/library/vendor/composer/autoload_real.php(8): spl_autoload_register(Array, true, true)
#1 /var/www/domain/web/library/vendor/autoload.php(8): uUBET::gbBbi()
#2 /var/www/domain/web/base/init.php(8): include('/var/www/domain...')
#3 /var/www/domain/web/index.php(8): require('/var/www/domain...')
#4 {main}
thrown in /var/www/domain/web/library/vendor/composer/autoload_real.php on line 8

I believe it's relevant with this one: #13

@pk-fr
Copy link
Owner

pk-fr commented Dec 26, 2016

Same issue same answer:

I do not have time nor will to deal with any third party product...

If you are able to provide and maintain a generic yakpro-po.cnf file for composer, wordpress, ... or whatever other third party product, I will be very happy to provide a link to your repository...

@pk-fr pk-fr closed this as completed Dec 26, 2016
@dzpt
Copy link
Author

dzpt commented Dec 26, 2016

Can you explain to use t_keep and t_skip i've tried to put vendor / composer directory for avoid obfuscating but didn't work.

t_keep = ['./library/vendor']

If can't make it work with composer, i need to exclude it

Are they absolute or relative path?

@pk-fr
Copy link
Owner

pk-fr commented Dec 26, 2016

$conf->t_keep = ['./library/vendor'];
is ok... (if you have php >=5.4 ... otherwise use array('') syntax ) but I think that you will also have to populate $conf->t_ignore_classes , $conf->t_ignore_methods, ... and so on...

@pk-fr
Copy link
Owner

pk-fr commented Jan 4, 2017

@tom29 relative paths are relative to the current working directory (the directory on which you are ) when you run yakpro-po...
It works as I use it on my own big project I wrote the obfuscator for...
the relating extract of my yakpro-po.cnf is the following:

$conf->source_directory             = '.';
$conf->target_directory             = '..';

$conf->t_keep                       = array('config.php','local','memo','3rdparty/ckeditor');
$conf->t_skip                       = array('00_RELEASE_00','mppksag');

and my current working directory is the projects root directory when i run the yakpro-po command

@dzpt
Copy link
Author

dzpt commented Jan 4, 2017

@pk-fr i just found the way to correct here.
the path needed to be 'library/vendor' instead of using absolute path.
if i ignored vendor folder, do i need to declare to ignore all classes, methodes, properties names ... of all classes inside the vendor path?

Because it's insane, there are numerous of them :(

@pk-fr
Copy link
Owner

pk-fr commented Jan 4, 2017

@tom29 you have to ignore all classes, methodes, properties names ...
that you use within your project....

@pk-fr
Copy link
Owner

pk-fr commented Jan 4, 2017

if you want to make a generic yakpro-po.cnf that will be usable to others, you will have to declare and maintain everything...

@dzpt
Copy link
Author

dzpt commented Jan 4, 2017

@pk-fr yeah, i know. i'm making a cnf files thinking about writing some script which can get all the classes, methods, properties inside one folder.

or simply disable naming obfustation for all of them. Because some properties inside that folder can match with many other classes of mine.

@dzpt
Copy link
Author

dzpt commented Jan 4, 2017

Hey, how's about t_ignore_pre_defined_classes ? If i put all the class name in vendor folder to it, will it work?

@pk-fr
Copy link
Owner

pk-fr commented Jan 4, 2017

by default:
$conf->t_ignore_pre_defined_classes = 'all';
you do not need to change it unless you want to obfuscate method names that are defined in a pre-defined class that you do not use...

@Phil795
Copy link

Phil795 commented May 15, 2018

To use composer it is necessary not to change the namespace references, or to adapt each namespace consiquently.

I have a configuration for composer, but adapted to Laravel

@pk-fr
Copy link
Owner

pk-fr commented May 16, 2018

good news...
If you publish it on GitHub, I will provide a link to your repository.

@Phil795
Copy link

Phil795 commented May 16, 2018

I will release a basic version for composer and one for laravel in the course of next week. Let you know when it's online :-)

@Connum
Copy link

Connum commented Jan 27, 2020

@Phil795 did this ever happen? ;)

@Phil795
Copy link

Phil795 commented Jan 27, 2020

@Phil795 did this ever happen? ;)

I'm afraid not. Switched to another payment solution in the same week.

But I still have the config for Composer in a project.

If the Composer configuration is sufficient for you, I can send it to you

@Connum
Copy link

Connum commented Jan 27, 2020

That would be great, thanks!

@oualid13
Copy link

oualid13 commented Feb 8, 2020

Hello,

Any news about the composer config?

Thanks

@Phil795
Copy link

Phil795 commented Feb 12, 2020

Unfortunately, I can no longer find the configuration.

But I can show you how you can easily create it

With this function you can print out all used namespaces. Build the output so that an array with the absolute namespaces is created and copy them into the config at $conf->t_ignore_namespaces.

    public function getNamespaces()
    {
      $namespaces=array();
      foreach(get_declared_classes() as $name) {
          if(preg_match_all("@[^\\\]+(?=\\\)@iU", $name, $matches)) {
              $matches = $matches[0];
              $parent =&$namespaces;
              while(count($matches)) {
                  $match = array_shift($matches);
                  if(!isset($parent[$match]) && count($matches))
                      $parent[$match] = array();
                  $parent =&$parent[$match];
              }
          }
      }
      print_r($namespaces);
    }

Hope it helps you

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

5 participants