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"
}
}
Related
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.
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.
I'm just getting started with Laravel / Composer. I want jquery to load with the composer autoloader.
My composer.json file looks like this:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"frameworks/jquery": "1.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"files":[
"vendor/frameworks/jquery/jquery.min.js"
]
},
"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"
}
notice i've added jquery to the require list and have added the jquery.min.js to the autoload / files. It loads, but as plain text, not as a js file.
This has to be something stupid I'm doing, but I can't figure it out. How do I get the file to load properly?
You cannot autoload jQuery with composer, because that would mean you want to execute Javascript on the server with the PHP script engine. This will never work.
What you want to do is include jQuery in the page you are creating with PHP. Probably include it as a javascript tag that loads it. Which means you have to configure a way to make that jquery.min.js file available on the server for HTTP access.
The frameworks/jquery package does not have any suggestions on how to do this. It simply grabs the files and adds it to the vendor folder. If you want it made available to the browser you'd either copy it into the document root, setup a script that reads the file and sends it to the browser, set a symlink to it, or add an alias to that vendor directory. All of these solutions are not that nice, but if asked I'd prefer the copy step.
There is a components/jquery package that uses another package to allow easy configuration of where to drop the files. You should investigate that, read the README. It looks much nicer to maintain and will essentially do the copy step.
I might be wrong but composer is used to autoload php files. It allows you to call something with out including it. This is all on the server side. I don't think you can do what you are trying to do.
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
I'm using the Laravel framework and wanted to include a library from GitHub. This is my full composer.json file:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.0.*",
"intervention/helper": "dev-master" <- this is what I've added
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/validators",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"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": "dev"
}
I've added "intervention/helper": "dev-master" under the require directive and when I do composer update on my local copy of the website, everything works fine and I can use the library.
I did a git push and pull to get it onto my live server, and when doing a composer update it doesn't download this library. This is the entire output of the command: http://pastebin.com/UgPNTaDw
I also tried composer install and composer update for a second time but neither worked. I've also verified that git retrieved the new composer.json file on the live server, and it has.
Why isn't composer recognizing the changes and downloading the library?
Besides the fact that your log does exactly tell you the "missing" library was downloaded, I have some general comment:
Are you sure you want to use EVERY library in DEVELOPMENT quality? Because that is what you enabled with the "minimum stability" flag: You are allowing EVERYTHING in possibly broken state from whatever development branch the libraries provide.
And the second thing is: You are supposed to update only once, on your development machine! Then test that everything still is working, and commit the composer.lock file!
Then push and pull that change to wherever you need it, and there only composer install - because you probably want the exact SAME library versions that you tested with, not anything slightly newer with possibly broken commits.
If you only want to use that particular library as development version, you should add that flag to the version requirement:
"intervention/helper": "dev-master#dev"
On the other hand, this library has released versions, so it might be better to require them...