Image Resizing Script required - a better one...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

So I can just add:
<?php
composer require imagine/imagine
?>

?? As it doesn't like that.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

No. You need to type that on the command line. Alternately, copy the contents I posted into composer.json and then run composer install (again from the command line).
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

[text]php composer.phar install[/text]
How do I run this? Via CMD prompt??
I did that but it didn't like it. Maybe it needs some file path??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

simonmlewis wrote:[text]php composer.phar install[/text]
How do I run this? Via CMD prompt??
Yes
simonmlewis wrote:I did that but it didn't like it.
What does that mean?
simonmlewis wrote:Maybe it needs some file path??
You want to run it from your project's root directory, where the composer.json file is located.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

Issue attached.
Attachments
install attempt
install attempt
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

Looks like an error in the composer.json file itself. Please post the entire contents.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

Code: Select all

{
    "name": "phpmyadmin/phpmyadmin",
    "type": "application",
    "description": "MySQL web administration tool",
    "keywords": ["phpmyadmin","mysql","web"],
    "homepage": "http://www.phpmyadmin.net/",
    "license": "GPL-2.0+",
    "authors": [
        {
            "name": "The phpMyAdmin Team",
            "email": "phpmyadmin-devel@lists.sourceforge.net",
            "homepage": "http://www.phpmyadmin.net/home_page/team.php"
        }
    ],
    "support": {
        "forum": "https://sourceforge.net/p/phpmyadmin/discussion/Help",
        "issues": "https://sourceforge.net/p/phpmyadmin/bugs/",
        "wiki": "http://wiki.phpmyadmin.net/",
        "source": "https://github.com/phpmyadmin/phpmyadmin"
    },
    "require": {
        "php": ">=5.3.0"
    },
    "require-dev": {
        "satooshi/php-coveralls": ">=0.6",
        "phpunit/phpunit": "<4.2",
        "phpunit/phpunit-selenium": ">=1.2"
    }
    
    "require": {
        "willdurand/geocoder": "@stable"
    }
}
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

That's not the right composer.json. What does your directory structure look like? The composer.json in question should live in your project's root directory, not Apache's.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

When I installed it, it just went to put it in a default area of xamp, in php/phpmyadmin.
Are you saying it needs to be installed for each and every website?
If that is the case, I guess I need to uninstall, and where it asks where to install, tell in the folder of the website.

Yes?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

Composer itself need only be installed once. It's a program, fundamentally. Each project gets its own composer.json file, though. This allows for project-specific dependencies.

For instance, I have composer installed to /usr/local/bin/composer but will have a composer.json in ~/Sites/<ProjectName> for each project. Clear?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

So if I run that composer command line again, but from the root of the project??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

simonmlewis wrote:So if I run that composer command line again, but from the root of the project??
Right. If you've copied the composer.json I posted earlier to your project root and run composer install from that same directory, it should pull in the dependencies for just that project and save them in a vendor directory.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

Gotchya. Done it in the right directory this time.
So do I jsut add an include "file.json" to the top of my admin page?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

So I now have a composer.json file in my project with that small bit of code you told me, anbout and a big composer.lock file.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

simonmlewis wrote:Gotchya. Done it in the right directory this time.
So do I jsut add an include "file.json" to the top of my admin page?
No. You want to include the generated autoloader, which is the line that was giving you the error earlier.

Code: Select all

require_once __DIR__ . '/vendor/autoload.php';
You may need to adjust which directory it looks in. The above will look in the current directory. You can wrap __DIR__ in dirname() to go up a directory and so on.
Post Reply