I have a
CI 3 REST project in my
Vagrant machine using the box
opifer/ubuntu-php7. Everything works fine in my development environment, but not in my
Amazon EC2 servers.
I have two free-tier instances:
- Ubuntu Server 16.04 LTS (HVM)
- Ubuntu Server 14.04 LTS (HVM)
I installed
Git, cloned the project and installed depencies via
composer in both servers. And also created the
config.php and
database.php files correctly.
Problems:
- The first problem I had was about case sensitive in the name of some libraries. I have some libraries named as WhateverLibrary.php that wasn't being found by the loader. I don't know why I didn't have this problem in my development environment. I solved this by changing the /system/core/Loader.php, doing:
PHP Code:
protected function _ci_load_library($class, $params = NULL, $object_name = NULL)
{
// ...
//$class = ucfirst($class);
$class = ucfirst(str_replace('library', 'Library', $class)); // workaround to fix prod bug
// ...
}
- The problem I'm facing now is about HTTP Verbs. I have a login_post() function called by the login form, but when I submit the form the server is returning "Unknow method".
After debugging CI 3 core code I got to know that $this->server('REQUEST_METHOD') is returning GET instead of POST in function method() of /system/coreInput.php.
Why this is happening and how to solve this?
And also, am I missing something in my setup? Because I'm having weird problems that I didn't have in my development environment, and the code is the same!
This is my form:
Code:
<form id="formLogin" style="margin-top: 5px;" name="formLogin" method="post" action="<?php echo site_url('login_home/login');?>">
<div id="loginFields">
<div class="row">
<div class="col-md-4" style="padding: 0; margin-right: 10px;">
<input type="email" id="login" name="login" placeholder="E-mail" class="form-control" required="required" />
</div>
<div class="col-md-3" style="padding: 0; margin-right: 10px;">
<input type="password" id="password" name="password" placeholder="Password" class="form-control" required="required"/>
</div>
<div id="contentLogin" class="col-md-4" style="padding: 0;">
<input type="submit" id="loginSubmit" name="loginSubmit" value="Enter" class="btn btn-primary"/>
</div>
<div class="col-md-12">
<a data-toggle="modal" data-target="#forgot_password_modal" href="#" style="color: #888686;font-size: 11px;margin-left: 124px;">forgot password</a>
</div>
</div>
</div>
</form>
And here is my controller:
PHP Code:
class Auth extends REST_Controller
{
function __construct()
{
parent::__construct();
}
public function login_post()
{
$this->input->post(); // does not work
}
public function login_get()
{
$this->input->get(); // work!
}
}