An entry point is a file or code which controls how your application initially "starts." For example, if you have a physical PHP page for every part of your website (home.php, index.php, users.php, contact.php, support.php, product.php, view.php, search.php, games.php, etc.)--then you would have LOTS of entry points to your application.
However, if you use CodeIgniter, then you only have a single entry point to your application, which is index.php. You load various parts of your site by passing parameters to the index.php page (index.php?page=home, index.php?page=search, index.php/product/view/13, etc.).
This brings you into the Model, View, Controller (MVC) framework design. Controller's are you "pages", Models are your database queries, and views are your HTML (very basic definition).
With an MVC framework, you use a router to determine which controller and action to run. For example, in CodeIgniter, your URLs look like this: domain.com/product/view/2. Product is your Controller, view is your action (which is a method/function in your controller), and 2 is a parameter you're passing to the view action. You can read up on CodeIgniter's routing here: https://codeigniter.com/user_guide/incoming/routing.html
But seriously though--CodeIgniter has GREAT documentation. I would strongly recommend you read it while playing with a basic site. https://codeigniter.com/user_guide/intro/index.html
> Hi guys, I came on here a couple weeks ago asking for resources to start learning PhP as I will be using it on the job. I’m an a new grad from the UK starting my job as a junior iOS dev.
Do you mean you'll be writing PHP APIs that you will be consuming through iOS apps? If so, take a look at RESTful API design.
> The senior Dev told me if they gave me the job, I should look in CodeIgniter because it’s what they use.
This is a bit worrying. CodeIgniter is quite old and hasn't aged very well. Most people who continue to use it are doing so because they don't know any better, are reluctant to change or are being forced to...
> Is it advisable to start diving into learning the framework after learning some OOP...
Yes. If you don't understand OOP you will be making life harder for yourself.
> ...or just continue to learn and start doing on the job.
If you think you can learn everything before you start your job you're delusional. You will need to do both.
> If so what best resources would you recommend to learn this framework.
I suggest (after finding out what version of CodeIgniter they use) that you read the relevant documentation:
>I was thinking maybe i should start learning dreamwiever - what the truly pro developers use
Stay away from dreamweaver. It's a very expensive, bloated P.O.S that generates garbage HTML. Take a look at something like Sublime or Visual Studio Code(they aren't WYSIWYG editors, but they are very very nice to work with).
I would suggest you look at CodeIgniter. It's a pretty lightweight MVC framework for web applications with quite a low barrier for entry. Think of a cool web service or website and then use CodeIgniter to build it. Maybe once you're quite handy with CodeIgniter go look at Laravel or CakePHP or Zend.
I find the best way to learn new things is to come up with a problem that I have, or that exists and then use that thing to solve it. Maybe build a grocery list web service(like just an API) with CodeIgniter and then an android app to connect to it and add/edit/delete grocery list items.
This would teach you about:
Optionally, you could expand that to include:
Happy to answer any questions on any of this.
The CodeIgniter documentation is pretty well written for beginners. https://codeigniter.com/user_guide/
Ideally you should be using version 3 of the framework because version 2 is really old. But it depends on what your job current codebase requires.
I've already built a database and began creating a PHP App. I'm a few days in development already with pure PHP. This is my first time building a PHP App. Before I've only used PHP sparingly for Wordpress website. Progress so far is slow but steady.
However*,* the code is already becoming cluttered and I'm very concerned about security. I've read PHP frameworks can help keep the code organized and make security easier.
My question is, do I need a PHP framework, and if so, which one would be best suited for a relatively simple, local App such as this one?
I've heard of Laravel before, and I've heard it's a fantastic framework. But from what I understand it is best suited for large, complex web apps. I feel it is an overkill for my needs. I've read CodeLinger and Slim are good lightweight frameworks. Do you have any experience with them?
I would prefer a framework that is easy to install and integrate into a project. E.g. I use XAMPP for development and like to include stuff the old-school way via link in <head>, be it a local file or via CDN. I would like to avoid using command line.
>I've got a plan to implement a complete web framework with all PSR recommendations.
Don't forget to add PSR-8 (here's an example implementation aka shameless self-plug).
Jokes aside implementing/incorporating PSRs is a good way to learn but try to keep at least two things in mind:
Nonetheless I hope you stay motivated and have fun :)
I'm in great part agree with everything FV68s said. But I want to add some things.
> > Do you mean you'll be writing PHP APIs that you will be consuming through iOS apps? If so, take a look at RESTful API design.
Be carefull when reading about RESTful API design. In one or two years, when you have a good level on web development look at Phil Sturgeon post's. There is a lot of mistakes about how people understand the concept of "RESTful" api, you might want to correct those. But, don't read it now, do it when you grow as a web-dev.
> > CodeIgniter is quite old and hasn't aged very well.
Even though CodeIgniter is quite old. I think is a good starting point to learn the MVC-ish pattern and understand how to design web apps. I think is easier to start with CodeIgniter and then jump to another Framework like Symfony or Laravel. Also, try to start using composer from the beggining.
I don't know how different are things in the CodeIgniter 3 community (It seems they build CI3 around composer), but in CI2 there was a lot of tutorials like "download those files, place them in X folder"
> > https://codeigniter.com/docs
Always, but Always, try at fist to learn from the documentation. Today most docs are a great resource, most of them are complete and explain things as they are. I have found a lot of tutorials/videotutorials on other frameworks who adds a lot of buzz word, make you loose a lot of time and teach you so little for the time they take to read. Always try docs first, then seek for help.
as mentioned, we would need to know what ORM you are using. MySQL is just the database engine, phpMyAdmin is a database client for directly adding/modifying the data.
What is the codebase you are working with. A quick google looks like the functionality of ActiveRecord (which code igniter uses), and if so, this guide may help (not sure how outdated the use is)
https://codeigniter.com/userguide2/database/active_record.html
Your syntax looks like CI3. There are many solutions for this. But my favorite is:
$this->db->db_select($database2_name);
And in this document page you will find all the information:
Probably not the right subreddit. But I can tell you how to accept a file upload.
First, what stack are you working with? That will make this a lot easier to explain. I usually work with CodeIgniter, which has a system for uploading files. CodeIgniter is a PHP framework, though, and I know PHP is getting less and less popular. I'm sure React has something that will handle this, and you can do it in pure PHP, too.
At the end of the day, the notion is this:
<input type='file' >
tag, the user selects a file for upload.Does that make sense?
>Password has two roles - it helps to find post_id
>else contain page data so it can be display
I don't understand the logic in doing this. Use the identifier for that or something else, like slugifying the title, like how blogs do. ie https://daringfireball.net/2021/09/iphone_names <- iphone_names is the ID for this post.
SELECT * FROM table WHERE slug = :slug
How to create something like this in CI - https://codeigniter.com/user_guide/helpers/url_helper.html#url_title
Or a random string like imgur/reddit does.
www.reddit.com/r/PHPhelp/pmgrai <- pmgrai is the ID for this page, which resolves to:
www.reddit.com/r/PHPhelp/comments/pmgrai/how_to_utilize_properly_multiple_if_statements/
>allow user to remove this post in the future
Why not just link the post to the user?
Post { id, slug, ... password, user_id }
# You could use this in lieu of user_id in the Post table UserPosts { user_id, post_id }
User { id, ... password }
# Using the user_id in the Post table
# Get all user posts SELECT * FROM Post WHERE user_id = :user_id
# Delete user post DELETE FROM Post WHERE id = :id AND user_id = :user_id
Could you care to elaborate on the "CI3 is dangerously out of date" statement? What exactly makes it dangerous? The last version (3.1.11) was released in 2019, and until version 4.1 a few months ago, CI3 was still the current stable version. According to codeigniter.com, "This version is in maintenance, receiving mostly just security update".
It would be more correct to say that CI3 is obsolete.
It looks like you're using CodeIgniter, but it's not possible to tell what version. You should specify the framework / library and version you're using when asking questions.
You can find CodeIgniter documentation on their site: https://codeigniter.com/docs
It's not exactly clear what you're trying to achieve here. You mention using a custom config file, but your code appears to be loading the encryption key from POST parameters. If the encryption key is to come from the config, I would not expect your code to be using ->set_item()
but ->item()
Additionally, your code refers to "password". Note that in general you should not encrypt passwords. You should use password hashing instead. PHP comes with a library to handle password hashing correctly: https://www.php.net/password
The only case where you might need to encrypt rather than hash passwords is if the password is for a 3rd party service - for example an SMTP mail server password.
The "public" directory should be the document root ("htdocs") folder for the project.
Modern PHP frameworks and applications are designed to separate the web-accessible document root from other files (code, configuration) to reduce the likelyhood of credentials being leaked or remote code execution exploits.
See, for example, an attack using a file included in phpunit, a popular test library, when the library (vendor folder) is web accessible: https://thephp.cc/articles/phpunit-a-security-risk
Consult the documentation for your framework. If you're still stuck, CodeIgniter have their own support forums and chat that should be able to help you: https://codeigniter.com/community
In future, please post support requests in the more specific r/phphelp subreddit
I don't have any experience using Codelnighter, but here are couple of tutorials that might help you out.
Here is a tutorial how to download, and install Codeigniter calendar library, it is phase to phase, so you should handle it from here.
https://kshitij206.medium.com/calendar-library-in-codeigniter-961af6f1bbb6
And here is a tutorial about how to build a calendar with it, after you have installed it.
https://codeigniter.com/userguide3/libraries/calendar.html
If you need further help, just search in Youtube, or Google, there are a lot of different tutorials, just relax, and read the instructions with thought. :)
Glad to hear it! Yes, I’m a maintainer for version 4 and a member of the organization.
I believe the ease-of-use is why CodeIgniter was so popular, and still makes the top ten “backend frameworks” every year. You certainly can still download it and throw it on your server, but I definitely recommend getting up to speed on Composer anyway so do check out the “Composer installation method” (https://codeigniter.com/user_guide/installation/index.html) - this will likely be akin to what you’re learning about Symfony.
If your not using 4.0 and you don’t want to setup .env you can add a config environment directory to .gitignore https://codeigniter.com/userguide3/libraries/config.html#environments then you’ll have a directory you can put config files in that doesn’t get checked in and isn’t an environment variable. Dotenv is really the way to go though. You put your production secrets in your apache configuration and just use the .env file for development.
A lot of good frameworks to try out (Laravel / Slim / Symfony 5 / Mezzio) have already been mentioned by others.
Looking into the current version of CodeIgniter (v4) might also be worth a shot. Another user also posted a video on how to get started with CI4 yesterday, maybe that helps too.
Best thing to do IMHO would be to just try a couple different ones and see what you like working with most.
That directory structure looks a lot like it could be CodeIgniter (https://codeigniter.com/). It's a fairly basic & opinionated MVC framework which uses the ActiveRecord pattern for its ORM. Think along the lines of Ruby On Rails.
I haven't used CI since version 1 or 2, however, so can't give much more insight other than that.
Just spotted this in the 'bug fixes', even though nothing was fixed and apparently it's a feature Bug: I am able to make POST request to a GET route #2880
In the bug report:
>If in your routes file, you have set the $routes->setAutoRoute(false)then it's a bug. Otherwise, not - because POST request to upload/index is still reachable, even if not defined directly.
Taking a look at the docs:
>When no defined route is found that matches the URI, the system will attempt to match that URI against the controllers and methods as described above.
>
>https://codeigniter.com/user_guide/incoming/routing.html#use-defined-routes-only
Routes will respond to all types of HTTP requests regardless of what's been defined and it will also automatically try and route requests to a controller if no routes are matched. Surely this is a bad idea and not something that should be enabled by default? What's the point in even defying the routes if it will just respond to any HTTP request type anyway?
You're referring to routing?
PHP does not by default have routing. What you need is a framework like Laravel, CodeIgniter, Yii, etc. You could build a routing function yourself, but that'd be a lot more unnecessary work.
You should join them in one query using MYSQL JOIN syntax, check the active record documentation.
CI changed it to Query Builder to be more explicit about that difference. Active Record is also a separate ORM project, albeit an old unmaintained one.