我的设置目前看起来像这样
应用/控制器/ register.php
class register_Controller extends Base_Controller
{
public $restful = true;
public function get_index()
{
return View::make('main.register');;
}
}
Run Code Online (Sandbox Code Playgroud)
routes.php文件
Route::controller(Controller::detect());
Route::any('/', function()
{
return View::make('main.index');
});
Route::any('register',function()
{
return View::make('register.index');
});
Run Code Online (Sandbox Code Playgroud)
mydomain.com有效.
mydomain.com/index给出了一个laravel 404
mydomain.com/register给出了标准404
有什么奇怪的是,mydomain.com/register不应该给我一个laravel 404错误? 此页面表明WAMP是原因,但我的设置是在运行PHP5,Apache2和mySQL的Ubuntu VM上.
Laravel 3上构建的应用程序是否适用于Laravel 4?
几天前,我找到了Laravel,现在我尝试学习它.当Laravel 4来临时,我是否会浪费时间学习Laravel 3?LV4中的一些插件是否相同?我的应用程序是否会在LV3中构建LV3?
在哪里以及如何开始学习LV4?
我的文件(126 MB大小,.exe)给了我一些问题.
我正在使用标准的laravel下载方法.
我尝试增加内存,但它仍然说我的内存不足,或者我下载了0 KB大小的文件.
该文档没有提到任何有关大文件大小的内容.
我的代码是
ini_set("memory_limit","-1"); // Trying to see if this works
return Response::download($full_path);
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
- 编辑 -
继续Phill Sparks评论,这就是我所拥有的并且它的工作原理.它是Phill的组合加上一些来自php.net的组合.不确定是否有遗失的东西?
public static function big_download($path, $name = null, array $headers = array())
{
if (is_null($name)) $name = basename($path);
// Prepare the headers
$headers = array_merge(array(
'Content-Description' => 'File Transfer',
'Content-Type' => File::mime(File::extension($path)),
'Content-Transfer-Encoding' => 'binary',
'Expires' => 0,
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Pragma' => 'public',
'Content-Length' => File::size($path),
), $headers);
$response = new Response('', 200, …Run Code Online (Sandbox Code Playgroud) 由于复杂模式和需要使用Fluent或Eloquent的库(不仅仅是原始DB :: query()),我需要创建:
LEFT JOIN `camp_to_cabin`
ON `camper_to_cabin`.`cabin_id` = `camp_to_cabin`.`cabin_id`
AND `camp_to_cabin`.`camp_id` =1 OR `camp_to_cabin`.`camp_id` IS NULL
Run Code Online (Sandbox Code Playgroud)
作为连接子句; 我已经尝试了回调和我能想到的其他一切,但无法获得正确的语法来生成.
我试过了:
->left_join('camp_to_cabin', function ($join){
$join->on( 'camper_to_cabin.cabin_id', '=', 'camp_to_cabin.cabin_id')
$join->on( 'camp_to_cabin.camp_id', '=', 1)
$join->on( 'camp_to_cabin.camp_id', '=', null)
})
Run Code Online (Sandbox Code Playgroud)
但它会在我的1&null(我知道空位不正确 - 试验)周围放置反引号,我无法摆脱; 否则它看起来非常接近
有帮助吗?
TIA
谢谢,菲尔 - 最后的答案是:
->left_join('camp_to_cabin', function ($join) use ($id){
$join->on( 'camper_to_cabin.cabin_id', '=', 'camp_to_cabin.cabin_id');
$join->on( 'camper_to_cabin.cabin_id', '=', DB::raw($id));
$join->or_on( 'camper_to_cabin.cabin_id', 'IS', DB::raw('NULL'));
})
Run Code Online (Sandbox Code Playgroud) 如何使用laravel分页增加行号?当我使用分页时,我转到第2页及以上,它将回到开头.例如,我将分页(3)
<thead>
<tr>
<th>No</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<?php $i = 1; ?>
@foreach ($telephone->results as $telp)
<tr>
<td>
{{$i++}}
</td>
<td>{{ $telp->name }}</td>
</tr>
@endforeach
</tbody>
Run Code Online (Sandbox Code Playgroud)
当我转到第2页时,该号码将再次从1开始.
当我转到第2页时,我需要制作它,它将从4开始
我是PHP和Laravel Framework的新手.我想在服务器端的Laravel中打印变量来检查它们包含的值.如何console.log在服务器上执行或打印变量值,以查看Laravel PHP中包含的变量值.
我在(梦幻般的)Laravel PHP框架上使用工匠时遇到了致命的错误.
我最近下载了Laravel的v3.2.1,并尝试在artisan所在的目录中运行以下命令行:
php artisan key:generate
Run Code Online (Sandbox Code Playgroud)
这应该在我的applications/application.php文件中为我创建一个随机密钥.(有关此命令的特定参考,请参阅http://laravel.com/docs/artisan/commands.)
但是,当我从shell运行此命令时,我收到以下错误:
Warning: chdir(): No such file or directory (errno 2) in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/paths.php on line 62
Parse error: syntax error, unexpected T_STRING in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/laravel/core.php on line 1
Run Code Online (Sandbox Code Playgroud)
这就是paths.php第62行的内容:
chdir(__DIR__);
Run Code Online (Sandbox Code Playgroud)
这是core.php的第1行:
<?php namespace Laravel;
Run Code Online (Sandbox Code Playgroud)
我的问题是:是否有任何特定的环境,目录或其他权限我应该修改以使工匠启动并运行.
一点背景:
我的环境:
我的根目录:(括号中的权限)
如果我的相关设置有任何其他详细信息,请告知我们.我真的不确定在解决此问题时有什么帮助.
-
更新:我还将此问题发布到Laravel的GitHub问题跟踪器.(https://github.com/laravel/laravel/issues/820)
我正在尝试在laravel中使用路由过滤器来检查特定用户是否可以访问页面:
Route::filter('check_roles', function()
{
$current_url = URI::current();
$access = 0;
$nav = Session::get('navigation');
foreach($nav as $k => $n){
if(in_array($current_url, $n)){
$access = 1;
}
}
if($access == 0){
return Redirect::to('home');
}
//problem is if the user has access to the page a blank page is returned
});
Run Code Online (Sandbox Code Playgroud)
我在这样的路线中使用它:
Route::get('admin/(:all)', array('before' => 'check_roles'));
Run Code Online (Sandbox Code Playgroud)
问题是如果用户有权访问该页面,则返回空白页面.如果用户有权访问,如何继续使用默认控制器操作?
我有一个系统,我需要列出一个任意数量的员工,其中包含一周中每天的文本字段,可以输入"小时工作"值.
所以我需要生成一个动态行数的表,每行将包含7个文本字段.我只是想知道在为这些字段分配ID时使用的最佳约定是什么,以便在我的后端收到输入数据后可以轻松迭代?
每行都有一个与代表员工ID的行相关联的ID号.
能够做到这样的事情真是太棒了:
foreach($rows as $row)
{
$id = $row['id'];
$employee = Employee::find($id);
foreach($row['hoursWorked'] as $dailyHours)
{
$timecard = new Timecard();
$timecard->hours = $dailyHours;
$employee->timecards->insert($timecard);
}
}
Run Code Online (Sandbox Code Playgroud)
在HTML方面构建表单和ID的最佳方法是什么,以使其尽可能轻松?
作为旁注,我正在Laravel 3框架内工作,以防其他任何解决方案开放.
我试图在laravel 3中捕获PDOException,但似乎我不能这样做.我的代码如下:
try{
DB::connection()->pdo->beginTransaction();
Myobject::create($cleaned_input_array);
// do other stuff that could possibly throw a custom exception
DB::connection()->pdo->commit();
}
catch(\PDOException $e)
{
DB::connection()->pdo->rollBack();
return HTTP_STATUS::response(BAD_REQUEST, array("error creating");
}
catch(Exception $e)
{
DB::connection()->pdo->rollBack();
return HTTP_STATUS::response(BAD_REQUEST, array($e->getMessage()));
}
Run Code Online (Sandbox Code Playgroud)
如果'try'中的其他部分抛出异常,则会捕获一般异常.如果他们不这样做,一切都很干净.如果create执行MYSQL语句时出现问题,则不会抛出PDOException,它只会抛出一般异常.
laravel ×10
laravel-3 ×10
php ×8
laravel-4 ×2
forms ×1
frameworks ×1
html ×1
mysql ×1
url-routing ×1