Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14108 articles
Browse latest View live

CodeIgniter Simple and Secure Twig


problem slash at the end of url

$
0
0
Hello,

I'm trying this url on my project:  http://localhost/ci4.0.4/about   
Result: works fine

but when I added slash at the end of the url like:
http://localhost/ci4.0.4/about/

Result: it redirect to http://localhost/about

This is my setup:
$baseURL = 'http://localhost/ci4.0.4/';

I'm using: wamp server under Windows10

any advice, Thanks in Advance,

Change Test Database Config

$
0
0
Hello,

i tried to change my Test Database Config within an FeatureTestCase.

I've changed the options within .env and Config/Database.php but at the end, during the test, the DBDriver is always SQLite3 and the database is always :memory: (see attachment).

Is that an issue or is it intentional?

Thanks

.png   ci4_3.png (Size: 38.08 KB / Downloads: 4)

.png   ci4_2.png (Size: 27.55 KB / Downloads: 2)

.png   ci4_1.png (Size: 7.53 KB / Downloads: 2)

Problem on save image in public directory

$
0
0
I have the structure below my project:

(private directories)

/home/my_porject/App/Controllers/Api/V1/FileController.php

(public directories)

/home/public_html/my_site/assets/images

I'm trying to send an Api file to the / images directory with file_put_contents but I'm not getting it. I've tried with:
file_put_contents (FCPATH. '....');
file_put_contents (APPPATH. '....');
file_put_contents (ROOT. '....');
file_put_contents (__ DIR__. '....');

I tried to change the permissions of the directory from 755 to 777.

And nothing worked.
What is the correct way to do this?

models in CI4 - OK to put in app/Models? What about naming/namespacing/autoloading?

$
0
0
I was reading the Model documentation for CI4 and it says :
Quote:Models provide a way to interact with a specific table in your database.

While I'm pretty happy to see CI4 supporting these types of database-specific classes, I also know from experience that there are many business logic situations which are not just interacting with a single database table. I'm wondering if it's an acceptable practice to create other types of classes in the app/Models directory. I.e., classes that either don't interact with a db table at all or which might interact with several tables using Composition/Aggregation/Assocation. For example, I might have some business logic that checks one or more tables and then creates a record in some other table. Or I might have some business logic which doesn't involve db tables at all but encrypts or decrypts data or enforces rules of some turn-based game or which calculates some funky calculation. Is it an acceptable practice to put this sort of code into classes in the app/Models directory? Is it OK if these classes don't extend any existing class? I'm also wondering what naming & namespacing conventions I should follow so that CodeIgniter's autoloading functionality will be sure to find these models when I refer to them in my code.

Any input would be much appreciated.

Route with variable gives 404

$
0
0
Hi all,

I'm new to CodeIgniter and have a routing issue.
What I try to do is add a variable to the URL to pass it into the method arguments.

I used this example from the CI manual:

PHP Code:
$routes->add('product/(:num)''Catalog::productLookupByID/$1'); 

The actual code to match my needs is:

PHP Code:
$routes->get('/backend/profile/''backend/Profile::index');
$routes->get('/backend/profile/(:num)''backend/Profile::index/$1'); 


The method in the controller is:

PHP Code:
public function index($var null): void
{
    echo $var;

    //some more stuff


When I run the URL http://localhost:8080/backend/profile/1

I expect it to echo "1".
But instead a 404 is thrown [Controller or its method is not found: \App\Controllers\backend::index]

This controller does exist, because when I remove the 1 from the URL, the page loads, however, it is echoing NULL obviously...

What is this beginner missing here???

MYSQL longtext return null value

$
0
0
Hello,

I have an issue with my codes. I use CodeIgniter 4.
I try to do a select on a table with a join. In the table Appointments, a field 'notes' is a longtext.
The query works fine for all other column except for the longtext field which return NULL everytimes (I check on MYSQL and it's not NULL).

Here is my codes :
Code:
$db = \Config\Database::connect();

$builder = $db->table('Appointments');

                $query = $builder->select('appointment')
                    ->distinct()
                    ->join("Clients", "Appointments.clientid = Clients.id")
                    ->where('Appointments.branchid', session('branchid'))
                    ->where('Appointments.appointment BETWEEN STR_TO_DATE(\'' . $datefrom . '\',\'%Y-%m-%d\') AND STR_TO_DATE(\'' . $dateto . '\',\'%Y-%m-%d\')')
                    ->get();

                $MISdetails = $query->getResultArray();

foreach ($MISdetails as $MIS) {
echo $MIS['notes'];
}

I used the $MIS['notes'] which return null (other value are not null).

Do you have any idea how to handles longtext column ?

My database configuration use MySQLi (I try also PDO).

Regards,

Xavier

Restream a m3u8 stream

$
0
0
Hello,
My name is Jose, am starting in programing with codeigniter, I want to develop a website to Restream m3u8 live stream from different sources. 
Wonder if there is a way in Codeigniter to do the following:

Get a stream url from a live video, supplied by other source and then ReStream in my page with different URL.
Like:

source: = http: //smptv.xyz:8588/livechannels/248766/live.m3u8

and on my page, the video is restreamed with the scr="video_channels-tocken?5284kddhw6J256.m3u8"

Thanks and waiting for some responses

Recommended version on website

$
0
0
Hi,

I have a question about which version to use - the download page says "CodeIgniter 4 is the upcoming version of the framework" whereas "CodeIgniter 3.1.11 is the current version of the framework".

My experience so far with CI4 makes me think that CI4 is the version to go with - is this text on the website just outdated?


(I sent this same question to admin@codeigniter.com, the email listed as the contact address on the website, but it bounced back...)

Thanks,
Dave

form with large files and input

$
0
0
HI , sorry for english , i must send one or several file (large file) and input  to save file and store input (text and textarea to db ) , i see plupload but i don't see how send input , wath can i use for this ?
.

dropdown from database

$
0
0
Model:
public function getAllUnitsDropDown()
{
    $builder = $this->db->table('units');
    $query = $builder->select('unit_id, unit_name');

    if ($query->countAll() > 0) {
        foreach ( $query->getResultArray() as $row ) {
            $data [$row ['unit_id']] = $row ['unit_name'];
        }
    }
    $query->free_result ();
    return $data;
}


result:
Error

Call to undefined method CodeIgniter\Database\MySQLi\Builder::getResultArray()

custom validation rule for IP in form

$
0
0
I am very new to codeigniter(have over 10 years php procedural experiance) and seems like i have run into issues from start. I am creating a auth for my site and in the sign up for i want to check IP not only if its valid but against a custom validation rule i made. I get the IP in the controller via "request->getIPAddress()".

Is there a way i can add the IP in the post method so i can use validation rules for it like they are used for fields that are passed from the form in my view?

No Content-Type Header

$
0
0
The possibility to remove the default Content-Type Header when using the HTTP\Response class.

Null Values in Validations

$
0
0
Hi! I have noticed that some rules like in_list, numeric, integer, doesn't accept NULL or empty values because it throws an error (I think CI3 accepts them). That makes the value to be required always, I think it shouldn't be like that because for that purpose already exist the required rule, is it supposed to work this way? what can I do to change that behavior?
Thanks!

Number of results is wrong

$
0
0
Hi,
I am a newbie with codeigniter 4.

I have a table with 3 entries each entry has a unique uniid. With my query I want to get the one entry with the corresponding uniid. This works but when I want to check if the result of the query has found 1 entry it doesn't work anymore, because the function countAll() always returns 3 instead of 1.

Can someone help me what I am doing wrong?


Thank you....


Code:
public function verifyUniid($id) {
  $builder = $this->db->table("users");
  $builder->select('activation_date,uniid,status');
  $builder->where('uniid',$id);
  $result=$builder->get();
  if($builder->countAll()==1){

    return $result->getRow();
  } else {
    return $builder->countAll();
  }

}

Database Configuration for ClearDB

$
0
0
I'm trying to deploy my CI4 app using Heroku and ClearDB for my database. I found a post for that tutorial but its still using CI3, it says i need to fill in my ClearDB setups in app/config/database.php. I store them in the $default class, but i have some trouble in setting the url for : $url = parse_url(getenv("CLEARDB_DATABASE_URL"));. I tried to set it in @var string as a public variable but its giving me error 'contains not valid' exception. Is there anyway I can do this? 

Thoughts on sending data to library from view

$
0
0
Hi

What are your thoughts on sending data to a library directly from a view and not a controller?

I know it does not follow the MVC pattern but here's why in this scenario i think its useful.

I'm working on a basic theme library that will parse the css and js files to the view dynamically dependent on what the developer wants / needs.

In most libraries this would be done in the controller doing something like this :

$this->Theme->add_css('file1.css, file2.css');

Its useful that we only include css and js files that are needed for that's specific page instead of having a huge list of additional files slowing down page load that may not be needed for that specific page.

But ...

If we want to develop themes for a specific application that may rely on different files for the same page then modifications would need to be made in the controller and its no longer a drop in replacement of themes.

for example lets say we have an application and on our customers page we are using datatables to display our data, we only load the specific css and js file for the datatables for that page. But what if our second theme does not use datatables and uses something else.

This is where i think it would be more efficient to add the required files from the view, allowing the theme designer to include the necessary files within the theme and would serve as a drop in theme with no modification to the controller.

What are your thoughts?

problem with library from composer

$
0
0
Hello,

I have a problem with my composer library.
I just start to use composer so, I made the setup and I have in my Application folder the composer.json, the composer.lock, I installed the phpspreadsheet library. All the files are in the vendor folder.
Finally, I change my config.php with the autoload composer to TRUE.

I have always the same error :

Code:
Message: Class 'Spreadsheet' not found



What have I forgotten ?
Thanks for the help.

CI4 is ready for development like airline management system?

$
0
0
Hi just want to ask if CI4 is ready for development like airline management system? or else i still use C3? please any suggestion?

HTTP Feature Request set body

$
0
0
Hello,

I've seen that in HTTP Feature (FeatureTestCase Class) Request it's possible to getJson from the Response. But it's also possible to set a Request body (with JSON for example)?

Thanks!
Viewing all 14108 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>