Search the Community
Showing results for tags 'composer'.
-
I've been using composer and like the idea of having managed libraries/dependencies in php. I'm having trouble understanding how to call libraries with autoloading. Some of the package authors give great directions and some don't. Things seem very inconsistent which is really annoying. For example I'm using this image library like this: use Intervention\Image\ImageManager; $imgMan = new ImageManager(array('driver' => 'gd')); //etc... Awesome! But I can't figure out how to do something similar with firephp and mpdf (namespacing)? I figured out that these do work: $firephp = FirePHP::getInstance(true); $mpdf = new mpdf(); But, why all the inconsistencies and different ways of doing things? I'd like to keep everything neat and namespaced all in a similar way. Can anyone offer some advice?
-
I want to install this package: https://github.com/composer/installers from GitHub, I can easily git clone it but I think its better I get experienced with composer. In the readme they onyl give one example, one involving CakePHP: { "name": "you/ftp", "type": "cakephp-plugin", "require": { "composer/installers": "~1.0" } } but I that isn't much help to me since I'm not making composer.json files to hold a single framework or plugin, my json files look more like this: { "name": "example-app", "require": { "cakephp/cakephp": ">=2.5.1", "cakephp/debug_kit": "2.2.*", "slywalker/boost_cake": "*", "CakeDC/tags": "1.*", "CakeDC/utils": "*", "CakeDC/migrations": "*", "FriendsOfCake/crud": "*", "CakeDC/search": "*", "paulredmond/chosen-cakephp": "*" }, "config": { "vendor-dir": "Vendor/" }, "extra": { "installer-paths": { "app/Plugin/Tags": ["CakeDC/tags"], "app/Plugin/BoostCake": ["slywalker/boost_cake"] } } } Right now I'm working on a WordPress one and it is 10 times longer than that. So what I was wondering is if its better to split it up into a few composer.json files. As in one file for setting up the framework and configuring it, when its done, it calls a second composer.json file that will take care of installing the plugins. Like this I suppose I could store a bunch of composer.json files in a central location, each of them has a specific purpose, so if I need to use one of them for a project, I just call composer.phar file (which I can access globally), and use that global keywork to make the json file operate like its in my projects directory. I don't understand what this autoload thing is about at all, but its nice the way it lets you run scripts at particular times during the execution of the json file. Is this actually a better way to work with composer, by chaining separate composer.json files together? A big issue is the name conflict thing, is there a way to make composer.phar process files with different names? It be a pain in the ass having to make the scripts alter the filenames. That gets me thinking about something. Can we define variables in composer.json files? If not, I suppose its not very hard to do it anyway by editing the file. I was thinking there that a composer file generator would be pretty useful. Like say on CakePHPs website, theres a page that lets you check plugins and features that you want for your new installation, then it makes a composer.json file for you.
-
I like to set up websites for people who don't have the know how to do it themselves, I mainly set them up wordpress sites cuz thats pretty easy for them to modify and maintain themselves. To save myself time, I decided to learn how to do it with Composer (what a brilliant tool that it). Can anyone who uses composer for this kinda thing, can you post your composer.json files here. Also, if anyone can show me a better way of doing things, it'd be much appreciated. Heres the one I made: { "name": "acme/brilliant-wordpress-site", "description": "My brilliant WordPress site", "repositories":[ { "type":"composer", "url":"http://wpackagist.org" } ], "require": { "johnpbloch/wordpress": ">=3.8.0", "wpackagist-plugin/captcha":">=3.9", "wpackagist-plugin/tinymce-advanced":">=4.0.0", "wpackagist-plugin/wordpress-importer":"*", "wpackagist-theme/hueman":"*", "wpackagist-theme/eclipse":"*", "wpackagist-theme/raindrops":"*" }, "extra": { "installer-paths": { "mysite": ["johnpbloch/wordpress"], "mysite/wp-content/plugins/{$name}": ["type:wordpress-plugin"], "mysite/wp-content/themes/{$name}": ["type:wordpress-theme"] } }, "autoload": { "psr-0": { "Acme": "src/" } } } I think I'm doing this in a silly way though. I read about these composer installer things on github, but I didn't figure out how to use them so instead I used the installer-paths key to make the autoloader put the files in the right place. Heres a composer.json file I found which is better cuz it uses a post installation script: { "require": { "wordpress/core": "3.5.2", "wordpress/twentytwelve": "1.1", "wordpress/akismet": "2.5.7", "wordpress/google-sitemap-generator": "3.2.9", "wordpress/google-analytics-for-wordpress": "4.3.3", "wordpress/wordpress-importer": "0.6.1" }, "repositories": [ { "type": "composer", "url": "https://raw.github.com/wordpressoncomposer/composer-repository/master/" }, { "type": "vcs", "url": "https://github.com/wordpressoncomposer/installer" } ], "scripts": { "post-install-cmd": "Wordpress\\Composer\\InstallerTasks::wpConfig" }, "extra": { "wordpress_coredir": "wordpress/core", "wordpress_wp_contentdir": "wordpress/wp-content", "wordpress_wp_config": { "site_url": "http://localhost", "db_host": "localhost", "db_user": "root", "db_pass": "", "db_name": "wordpress" } }, "minimum-stability": "dev" } I'm gonna start using these scripts once I figure out how to use them. Where are the scripts stored? I haven't a clue what this autoload thing is all about either, is it a tool for moving files into the appropriate directories? See how the first file gets wordpress from packagist, and the second one gets it from github. Is there a difference? If I was to add that post-install-cmd key to the first composer.json file, would it still work? In other words, do both repositories contain identical packages.
-
I'm beginning to study Composer and am developing a system where I separate the files core application files, as follows: /root |-- /src |-- /App |-- /DBConfig |-- /Controller |-- /Model |-- /Core |-- /Helper |-- /Controller |-- /Model So, to set this setting in composer.json file and get access to all classes both /App much /Core would be this way? "autoload" : { "psr-X" : { "App\\" : "/src", "Core\\" : "/src" } } Or is there a more correct way? I have also read about PSR-0 vs PSR-4 and I am still somewhat in doubt which one to use. In my case what should I implement, PSR-0 or PSR-4?