laravel-4

Heroku doesn't recognize my Laravel app as PHP app, and does not do composer install

僤鯓⒐⒋嵵緔 提交于 2019-12-03 14:52:47
I'm trying to publish my Laravel app on Heroku. I have excluded the composer.lock file from .gitignore, and created a Procfile containing web: vendor/bin/heroku-php-apache2 public I created my app with heroku create myapp; git push heroku master; Then I get the following output: git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags heroku master:master Pushing to https://git.heroku.com/myapp.git POST git-receive-pack (1914 bytes) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Node.js app detected

How to simulate xmlHttpRequests in a laravel testcase?

我怕爱的太早我们不能终老 提交于 2019-12-03 14:43:55
Updates see below My controllers distinguish between ajax and other requests (using Request::ajax() as a condition). That works quite fine but I wonder if there is a way of unit testing the controllers handling the the requests. How should a test look like? Something like this probably but it doesn't work ... <?php class UsersControllerTest extends TestCase { public function testShowUser() { $userId = 1; $response = $this->call('GET', '/users/2/routes', array(), array(), array( 'HTTP_CUSTOM' => array( 'X-Requested-With' => 'XMLHttpRequest' ) )); } } Update I kind of found a solution. Maybe.

Laravel 4 Blade @include variable

纵饮孤独 提交于 2019-12-03 14:38:43
问题 I was trying to do include with Laravel blade, but the problem is it can't pass the variable. Here's my example code: file_include.blade.php <?php $myvar = "some text"; main.blade.php @include('file_include') {{$myvar}} When I run the file, it return the error "Undefined variable: myvar". So, how can I pass the variable from the include file to the main file? Thank you. 回答1: Why would you pass it from the include to the calling template? If you need it in the calling template, create it there

How to echo to console in Laravel and Artisan?

跟風遠走 提交于 2019-12-03 14:38:37
问题 I was curious, I'm using Laravel and Artisan for my migrations. Is there a method to output information to the console? I can't seem to find any information on this. For example: <?php class Generate_Sample_Users{ public function up(){ //Echo to console here echo "Creating sample users..."; $generator = new Sample_Data(); $user_count = 30; $users = array(); for($i=0; $i < $user_count; $i++){ array_push($users, $generator->generate_user($i)); } DB::table('users')->insert($users); } public

Laravel 4: loading an old library: how?

≡放荡痞女 提交于 2019-12-03 14:18:58
I have an old library ( phpquery ) that I'd like to include in my project. I've put it inside vendor, but it doesn't work, as it's not PSR-0 compliant. I don't want it to load for every request, so I didn't put the require inside bootstrap autoload.php. I don't even know, how I can get the root of the app. Running path() gives me a URL, not what I'm after. So how can I do that? You can create a libraries directory just like in laravel 3 and include it in your class loader. You can do this via composer or laravel. //composer.json "autoload": { "classmap": [ "app/commands", "app/libraries", "app

Creating Image link with HTML Helper

删除回忆录丶 提交于 2019-12-03 14:08:08
I'm trying to create an image link with the HTML helper of Laravel 4. But it seems that isn't really working. I have this line of code {{ HTML::link("#", HTML::image("img/logo.png", "Logo") ) }} But that just outputs a strin like this: <img src="http://localhost/worker/public/img/logo" alt="Logo"> How come.?? You probably will have to: <a href="#">{{ HTML::image("img/logo.png", "Logo") }}</a> Because, link() uses entities to escape the title: public function link($url, $title = null, $attributes = array(), $secure = null) { $url = $this->url->to($url, array(), $secure); if (is_null($title) or

Laravel 4 Pagination bug with Twitter Bootstrap 3

送分小仙女□ 提交于 2019-12-03 13:49:55
When using Laravel Pagination, I believe that the css classes generated are relevant to bootstrap 2 and not bootstrap 3. {{ $products->links() }} generates <div class="pagination"> <ul> <?php echo $presenter->render(); ?> </ul> </div> However I would like it to generate: <ul class="pagination"> <?php echo $presenter->render(); ?> </ul> Without changing the framework code laravel/framework/src/illuminate/pagination/views/slider.php , is there a better / proper way of overriding the CSS / code generated by {{ $products->links() }} ? I saw something in one of the latest update, I haven't tried

update pivot table in case of many to many relation laravel4

倾然丶 夕夏残阳落幕 提交于 2019-12-03 13:44:45
I have started working with Laravel4 recently. I am facing some problem while updating pivot table data, in case of many to many relation. The situation is: I have two table: Product , ProductType . The relation between them is Many to many . My Models are class Product extends Eloquent { protected $table = 'products'; protected $primaryKey = 'prd_id'; public function tags() { return $this->belongsToMany('Tag', 'prd_tags', 'prta_prd_id', 'prta_tag_id'); } } class Tag extends Eloquent { protected $table = 'tags'; protected $primaryKey = 'tag_id'; public function products() { return $this-

Can't authenticate user in laravel

北城余情 提交于 2019-12-03 13:42:32
$userdata = array( 'email' => Input::get('email'), 'password' => Input::get('password') ); if (Auth::attempt($userdata)) { echo 'SUCCESS!'; } else { return Redirect::to('login'); } when i run the application from browser i got this error : Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Auth\UserInterface, instance of User given, called in /home/srtpl17/Sites/yatin.sr/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 316 and defined What have I done incorrectly? TonyArra It sounds like from your error that your

Laravel 4.1 Deployment - Production .env.php not being recognised

孤街浪徒 提交于 2019-12-03 13:27:22
问题 For some reason, my production laravel app thinks that it is in the local environment. /var/www/appname/.env.php <?php return [ 'APP_ENV' => 'production', 'DB_HOST' => 'HIDDEN', 'DB_NAME' => 'HIDDEN', 'DB_PASSWORD' => 'HIDDEN' ]; /var/www/appname/bootstrap/start.php $env = $app->detectEnvironment(function() { return getenv('APP_ENV') ?: 'local'; }); /var/www/appname/app/config/database.php ... ... 'mysql' => array( 'driver' => 'mysql', 'host' => getenv('DB_HOST'), 'database' => getenv('DB