How to correctly configure Imagine in laravel 4.2 - php

I had a requirement in laravel, where i needed to some server side cropping using the the laravel package Imagine, now i followed the installation instruction for this package for my application, I.E. :
I added the below line in my composer.json file:
{
"require": {
"orchestra/imagine": "~3.0"
}
}
My composer.json file looks like below now:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*",
"intervention/image": "dev-master",
"orchestra/imagine": "~3.0"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
Now when i run composer update from the terminal , i get the following messages:
and i have now followed THESE INSTRUCTIONS too, of adding the alias etc to the config/app.php,
Now when i try to load my admin panel , i get the following error:
Class 'Orchestra\Imagine\ImagineServiceProvider' not found
Why am i getting this error , can somebody explain ?

You are using laravel 4.2.* and imagine "~3.0" with it. imagine "~3.0" is for laravel 5.1. So try using correct version. Version compatibility image below

Related

Composer update "PHP Warning: unexpected character" error message Laravel-4

I do not understand where this error is coming from. I first noted it after installing a third party package, and thought that was the problem. Uninstalling the package made no difference. Reverting to an earlier version of Laravel also had no effect. (So now I'm back to the current version, 4.2.8.)
Here is the full error message in response to $ composer update -- the error is repeated 7 times, right after "Generating autoload files":
PHP Warning: Unexpected character in input: ' in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php on line 118
This appears to refer to a corrupted piece of code in composer itself, rather than a corrupted file in the Laravel tree. My copy of composer lives in /usr/local/bin and the only file in that directory is composer. The warning appears to suggest that composer is a directory, but of course it's not. There is nothing on line 118 in composer itself.
I have no idea how to fix this, or how important it is, or how to find where the problem is. Do I need to reinstall composer?
Thanks for any help.
In response to a comment asking about whether composer.json is the problem, here's my entire composer.json file. I can't identify any errors there:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/libraries"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
And here's lines 116-123 from composer.lock -- could the problem be here? :
"autoload": {
"psr-0": {
"Whoops": "src/"
},
"classmap": [
"src/deprecated"
]
},
Thanks.
Problem solved simply by running
composer self-update
Thanks much to help from Marwelln and WereWolf.

Composer: required packages with differing levels of minimum-stability

I have a composer file for a laravel installation with the following composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
I'm trying to add in the bundle for sentry. On sentry's website it says I can install it by adding the following to my composer.json file:
{
"require": {
"cartalyst/sentry": "2.0.*"
},
"minimum-stability": "dev"
}
I tried adding the new json object at the end of the current laravel one like so:
...
},
{
"require": {
"cartalyst/sentry": "2.0.*"
},
"minimum-stability": "dev"
}
When I run the composer update command to load the new package I get an error saying that the new object addition is not valid json.
If I add the cartalyst/sentry to the existing require object it cannot find the sentry package because the existing requires have a minimum-stability value of stable.
Is there a way of specifying the sentry package in a separate require object that has the minimum-stability setting of dev?
The answer is just add #dev
{
"require": {
"cartalyst/sentry": "2.0.*#dev"
},
}
You can read more about minimum stability settings here.
An alternative is to set your minimum-stability to dev, but tell composer you want to use stable whenever possible:
"minimum-stability": "dev",
"prefer-stable" : true
This basically means it will always use stable UNLESS there is no way to install a stable dependency, and therefore use dev.
You can also use other levels of stability, like alpha, beta combined with version selector.
Examples
With caret operator - maximum of version 2 allowing beta:
"cartalyst/sentry": "^2#beta"
Any version allowing alpha
"cartalyst/sentry": "*#alpha"
From the composer documentation:
To allow various stabilities without enforcing them at the constraint level however, you may use stability-flags like # (e.g. #dev) to let Composer know that a given package can be installed in a different stability than your default minimum-stability setting.
https://getcomposer.org/doc/articles/versions.md#stability-constraints

Laravel Error with str.php in vendor directory

For some reason I started getting this error after a few days. I didn't change anything from the time my Laravel application was working to the time it threw this parse error:
Parse error: syntax error, unexpected T_USE, expecting T_FUNCTION in /home/fzystudi/public_html/vendor/laravel/framework/src/Illuminate/Support/Str.php on line 7
Here is the site live with error.
Here is what I tried for solving the errors:
I wiped everything clean and installed laravel again. Same error. So I then did composer update. Still no change. I did composer update again and still no change.
I also downloaded the developer version and stable version. Still no difference.
I cloned the exact file from str.php and the file is the same on github as it is in my app on my ftp server.
I uploaded to hostgator and A2 hosting. Same error on both sites.
Here is the thread on the laravel forum I posted. No one has been able to help yet.
What seems to be the cause and what is the fix?
This is my controller:
<?php
class SiteController extends BaseController {
public function __construct() {
//parent::__construct();
$this->beforeFilter('csrf', array('on'=>'post'));
}
//homepage for our store
public function getIndex() {
return View::make('site.index');
}
}
My composer.json:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/laravel": "4.1.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
This sounds like you're getting the bleeding edge version of Laravel which has started to make use of traits. I'm assuming line 7 of the Str.php file in your vendor directory is something like this?
use MacroableTrait;
You should check your composer.json file to make sure you're depending on the stable release of Laravel 4.1.
"laravel/laravel": "4.1.*"
You may need to delete your vendor directory again as well as the composer.lock file. If you don't remove the lock file you'll just re-install the same dependencies again. Once installed you can check the version you have by running artisan --version from your command line in the installed directory.

Getting white screen of death on deployed Laravel app

Earlier today my Laravel app on Fortrabbit was working fine but after pushing to the app white pages started to be displayed instead of any content. I can still directly access any assets by explicitly specifying the path but if I try to access my index page or any other that work both locally and on previous versions of the application I get a white screen with no content.
I've tried removing the /vendor directory and composer.lock and updating composer to get a fresh start. I've also looked into the logs given by the Fortrabbit service in the php and apache directories and neither are reporting errors. I've also looked into the logs for Laravel and this also didn't provide any error messages that could help me debug the issue.
Was wondering if anyone had experience with this issue and could offer steps to attempt to resolve it, thank you!
Notes:
I'm using Laravel v4.1.*
The commit that began causing the issue contained no changes to PHP code (only SCSS files)
I've run php artisan dump-autoload already
I can run php artisan tinker and interact with the MySQL database just fine with my models
My composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"way/generators": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}

Composer update not working to update laravel dependencies

When I try to run composer update, I get the following error:
[RuntimeException]
Error Output: '$_' is not recognized as an internal or external command,
operable program or batch file.
I am not sure why this happens, but I have tried updating composer itself (which runs successfully) and it does not work. Composer usually works just fine, so I am a little bit confused.
Added composer file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"bogardo/mailgun": "dev-master"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
I seem to have solved my problem. I need to keep the scripts because it powers my deployment. I needed to run composer update --no-scripts and it worked perfectly.
I think the problem is located in your code.
Try to run
php artisan
if the error gets thrown also it is a problem in your code.
composer
fails also because in the
scripts
section you run php artisan.
try this command composer update --ignore-platform-reqs

Categories