PHP Project : How to handle general configuration data? [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm currently starting the conception of a new project that will use either Zend Framework 2 or Symfony 2.
I am currently wondering, as I'm quite a newbie in data modeling and application conception, how to handle general configuration data that wouldn't be linked to my entities. For example, I have constants, numbers, and maybe even texts and medias that should be configurable via an administration and that concerns the whole application, but that is not related to my Model data (for example, the maximum price of products, some general ranges, etc.. that I don't know at all how to store).
So, should I :
Create a "parameter" table or something related, that would store all my global parameters of my application?
Use INI files or YML files (like in Symfony, if I finally use this one) to store my parameters? If so, how to handle them? What are the best practices?
Any better solution for that task?
The only possibility I found was with Symfony, using config.yml files or generally YML files to store my general configuration. But what are the best practices for this kind of storage? How to securely manage them?
I hope this question is not too general.
Thank you.

Personally, for most of my bigger projects I use both file and database solutions combined together (and i know a lot of people do that).
Configuration table in database to store all parameters that can be configured via CMS / Admin Panel.
One bigger INI / YAML file to keep base configuration of the application.
Many smaller INI / YAML files for modules / functionality / routes etc.
These INI / YAML files are kept out of code versioning, changed rarely and also cached.
For getting these values inside code i use only one ConfigManager class with priorities like database value -> partial file value (dependant on module etc.) -> main file value.
P.S. YAML (native for Symfony) is really good, i wouldn't be changing it to INI if i had it already implemented.

Related

Managing php config with ansible - lineinfile php.ini vs copy to php.d? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I'm learning ansible and looking to automate php configuration.
When I look at examples, nearly all are using lineinfile to change /etc/php.ini
This approach works, but seems a bit brittle to me.
Wouldn't it be better to add a custom /etc/phpd./90-site.ini file with all the options you want to customize in one whole shot using copy or template? This depends on PHP being compiled with the --with-config-file-scan-dir=/etc/php.d option but that seems to be the case mostly nowadays. And the actual ansible code will be dead easy, with all the configuration in a template file.
What am I missing?
What are the pros and cons of overriding a configuration file using a multiple lineinfile tasks versus a single copy task?
Without getting into an opinion based answer, let me point you to a hint on the lineinfile module's documentation:
This is primarily useful when you want to change a single line in a file only.
Considering this, if you have multiple lines of configuration to change, using template module to manage a file like - /etc/php.d/90-site.ini makes sense.

Core PHP or Laravel for more complex projects [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am confused about using core php or a framework for my new project. I have done projects in Laravel, Codeignator and some in core php. My project requirements keep confusing me as to which is the better choice. Can anyone suggest best option for me? The following are the functionalities i need to implement in that project:
1) I Should need to upload 30 images at a time. Images with larger size so need to compress the images without losing the clarity and decompress after uploading.
2) I need to integrate lots of API's include Google’s Cloud Vision, MaxMind GeoIP so on..
3) Need to implement two databases; MySQL and Cassandra
4) Need to create user profiles based on there activities inside the website. These content stored in cassandra database
5) Implement Elasticsearch for real time analytics
Can anyone suggest can i go with core php or Laravel?
This is a really broad question, and one that will draw answers based primarily around one's opinion as your project can be achieved with both Core PHP or Laravel.
Given your requirements I would suggest you use Laravel. Starting a project from a framework means that a lot of the initial work has already been done for you and the framework itself will do a lot of the heavy lifting.
The API's, Elasticsearch, and image resizing can all be incorporated through various packages and Laravel's blade engine will help you create consistent views without the repeating your HTML code over and over again.
Using two databases is as simple as setting up two database connections and then ensuring your queries are using the right one.
Remember that Laravel is essentially just Core PHP, it has all just been structured in to a framework - specifically to improve the ease of use and performance.
As per my opinion Laravel is best for your project requirements. Your all functionalities are easily cover in Laravel as compare with core PHP.
In your project for further enhancement Laravel is best choice because of there are so many libraries are available for lots of functionalities.
Your project development timing also decrease as compare as core PHP.

centralize PHP code and MySQL data [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I currently have a dedicated server and I'm looking to set up a MySQL database, PHP query code and images directory that can be used by multiple sites. A majority of the sites will be hosted on the same machine, but some will not. My simple way of thinking is that this is possible similar to how Roundcube's code and database is centralized.
Looking for some expert input and direction on whether or not it is this simple or if there is a better way of accomplishing this.
In my opinion, you could two a couple of things to improve your situation:
store your images in just one place, and use that place as a CDN to deliver contents across your sites;
About your code:
if it's possible, use packages in order to create a single package for all the "common" code;
use this package on every site that needs that code, as a simple dependency. Tools like Composer are great to handle dependency management;
No big problems with MySQL databases unless you have big traffic numbers. In that case, you should study MySQL scaling. But first of all, focus on PHP and common assets (like images).
EDIT:
be sure to set appropriate permissions for the external sites, of course;
using packages for your dependencies will be very useful also for sites placed outside the dedicated server;

What to include in software metric calculation on laravel project? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Laravel project contain a lot of files and folder.
When we are calculating the Software Metric, should we include them all?
I am using phpmetric but it ignored the vendor folder.
But when I use phpdepend , it included that folder.
Thanks.
It depends on what you're measuring, which is why there's no one answer and similar tools may, or may not, include the vendor folder.
If you're interested in the analyzing your own project, then you'll want to point these tools at files you'll be editing. In Laravel 5 that mostly means the app folder -- but you might want to include config and bootstrap, as user created code often finds its ways in those folders.
A reason you might point it at vendor is if you were concerned about the direction a particular code library you use is going, and wanted to measure it over time.
Hope that helps!
vendors (external code) is not important for you. When you measure your project, you should measure YOUR code only:
vendors are already tested / measured in their own repository
if you include external librairies, you don't measure your work
your should exclude generated files (cache...). They are not representative of your work
you should exclude test files : they do not obey the same quality rules
If you want to get information about a particular code library you use, you can check the Github repository of this library. There is a list of PhpMetrics representations of main PHP projects, you can also keep on eye on it.

Framework for storing settings in a database (PHP and MySQL) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
So after considering my options, I've opted to go with a database storage system to store applications settings. Given the fact that these settings will ultimately be changed every so often by the user, I decided implementing them into a database versus a config file (e.g. .ini file). What we're thinking of doing is storing these settings in a key/pair manner. The only trouble I'm having is finding an efficient way to access and write settings into the database.
My question is, are there any frameworks that you may use/heard of that helps to deal with this type of scenario? The only thing I've managed to find is endless discussions about the storage methods along with their pros and cons but nothing related to implementation of these methods.
Every framework. But. Why do you even need entire FRAMEWORK to just connect to database? Use native PDO included to every PHP installation. Use SQL libraries or plugins. Or consider using XML/CSV/INI files.
Still wanna frameworks that help with database? Here you go:
Yii
Zend
Symfony
Codeigniter
Laravel
Fat-Free
Kohana
CakePHP
Joomla
etc
"Full" list

Categories