Migrate file in php - php

I am working on a Laravel project. We currently have a config file for our customer (number of data they can store, their type ...). The config file is config.php.example. When we deploy to our customer, we change the config.php.example to config.php and modify the content of config.php to fit our customer demand
The problem is that the config file (config.php.example) will continuously change due to business goal. And when someone add some config, our team must check all the old config and compare them with the new one. I believe that it is not a good way to solve this problem. I guess we can do something like a migration for a PHP file
I tried to search but it does not work. Could anyone give me some keywords about this situation ?
Thanks in advance

Related

PhpStorm - move refactoring does not work for file paths

I have the following folder structure:
Previously, the classes were placed directly in /rest/ folder and they were referenced so in autoload.php:
After doing Refactor->Move for all classes in PhpStorm to /rest/class/ directory, PhpStorm does not refactor string file paths (seen on the above screenshot). Does someone know why is that? Standard filename refactor works fine. Is there better way to change folder structure for the project without the need to check all the references in other files?
This issue has been reported some time ago as https://youtrack.jetbrains.com/issue/WI-33398 but did not have much votes there. Would be great if you could vote for it with Thumb Up button and leave a comment to get a devs attention.

Laravel: Join two application by one config

My project is two Laravel applications in one folder. Why two separate applications instead of one? I have good reasons. Anyway, for example, every time I want to change the app name in the config (config/app.php) I go and edit the .env file in both directories (of the two applications) and then execute artisan config:cache to update the cached config.
It's not much of a task or anything, but it's a bad design I believe. So, I am looking for a way to take the values shared between these two application out to a separate file. And have these application load this file and override/apply the values inside it to the app configuration.
So, now I have a config.php in the root directory (which holds the other two apps in /app1 and /app2). And inside each app's AppServiceProvider I call the config.php and loop through the values and set each using Config::set(..., ...).
This worked for me well, but of course changing the values loaded in the \Config package doesn't change the values that were fetched from it earlier to this point. For example app()->environment() returns the value set in the config/app.php, not the new value introduced in the global config.php. That's because the App library asked for the env property before I could override it!
So, what I want your help with is: you either tell me about a more smart/standard way to achieve 1 config for 2 apps setup. Or tell me where to put the code that overrides the app config with the new values from my global config.php (currently I put the code in register() in App\Providers\AppServiceProvider)
You can share env settings by removing one of .env files and make a symlink to the other file instead of a common file. In this case if you change a file, both applications get changed values.

Run a laravel application

I am absolutely new to laravel. I have an open source laravel application for which I have downloaded the code. I was able to get the home page running using these links:
https://www.rosehosting.com/blog/install-laravel-on-ubuntu-16-04/
https://askubuntu.com/questions/764782/install-laravel-5-on-ubuntu-16-04
http://idroot.net/linux/install-laravel-ubuntu-16-04/
https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/
none of the other webpages are running. I have to manually change the path in the address bar from localhost/public to localhost/public/index.php. Even after this, the webpage that executes, shows no css.If I try to register a user, I get
SQLSTATE[HY000]: General error: 1364 Field 'username' doesn't have a default value
I have referred to the following links in an attempt to solve the issue but no use -
Access denied for user 'root'#'localhost' - Laravel
https://laravel.com/docs/4.2/quick#routing
https://laravel.com/docs/5.1/quickstart#database-migrations
https://laravel.com/docs/5.1/database
I don't have any data in the database as I cannot understand how to import it. My directory structure is
/var/www/laravelApplicaton
-app/
-artisan
-bootstrap/
-composer.json
-composer.lock
-config/
-database/
-gulpfile.js
-package.json
-phpunit.xml
-public/
-readme.md
-resources/
-routes/
-server.php
-storage/
-tests/
-vendor/
I am using ubuntu 16.04 server; Php7.0.
OK, you're using Laravel 5.3 as your folder structure shows. There if you closely look there's no any .env file. Do create that because Laravel first seeks for .env file for configurations if that doesn't exists, then it looks for key value pairs in configuration folder i.e config. So if you have got .env file do change database information there or you can change that from /config/database.php. But the good practice is to use .env file on development machine. It's shown here in this link, the way to create .env file:
https://www.rosehosting.com/blog/install-laravel-on-ubuntu-16-04/
And for "username doesn't have a default value" issue, you have not passed value for "username" while inserting, this problem arises if you have username field that can't be null in your database structure.
The best option to play with Laravel is to use composer. Please follow the laravel 5.3 documentation for installation process.
https://laravel.com/docs/5.3/installation
And for beginner Laracast.com have very nice series to get started with Laravel from scratch, I myself have used this tutorial series to get started with laravel.
https://laracasts.com/series/laravel-5-from-scratch/episodes/1
Do check all those episodes out, once you finish you'll be now very much familiar with Laravel.
Hope this helps you.

Loading Config and Setting a Config Value in CodeIgniter

I try to create application with back-end and frond-end. The folder structure as follows(only show config file position to explain problem)
+root
|-admin
|-application
|—backend
|—config
|—config.php
|—frontend
|—config
|—config.php
|-system
Using back-end admin panel I try to change config value in both back-end and frond-end config.php value. But I fail to change it in front-end config.php file. I don’t need database based solution for this.
Reading the documentation I got this:
Note: CodeIgniter always tries to load the configuration files for the current environment first. If the file does not exist, the global config file (i.e., the one in application/config/) is loaded. This means you are not obligated to place all of your configuration files in an environment folder − only the files that change per environment.
So based on that information, I think the problem is when you are calling it, maybe a problem with your path.

Modular Zend Framework app & Doctrine integration and usage

I need help, cause I am little stuck on this.
I have set up a modular Zend Framework app. Also using -- https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD- -- i integrated Doctrine 2.
My directory structure is like this:
-aplication/
--default/ --module1
---config
---controllers/
---forms/
---models/
---templates/
---test/
--maintenance --module2
---config
---controllers/
---forms/
---models/
---templates/
---test/
-config
--Bootstrap.php
--aplication.ini
-library/
--Zend/
--Doctrine/
--doctrine.php
--cli-config.php
-sites/
--site1/
---index.php
I have my databse created. I will use some tools to generate YAML files from database.
The next step I want is to generate model classes from these YAML files.
I spend days searching, but I just coudn't find solution to generate classes to models folder of each module. OK, so I would solve the problem by generating these classes in one directory and then move it to their 'original' destination (models folders).
I need help on how to generate these classes. I am developing in Windows, and that is where I want to generate this.
I suppose I have to open cms, point to location of doctrine.php (in library folder) and enter command php doctrine.php + some arguments. But when I do that i have:
[InvalidArgumentException]
There are no commands defined in the "" namespace.
What am I missing? What am I doing wrong?
I will also try to contact author of these files https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD- to ask for explanation.
Thanks in advance. I would really appreciate your help.
If you need I can write some of my code from Bootstrap and application.ini if you need.
Try to generate the class from YML file .It is possible to use MySQL workbench to sync the database tables and then use the MySQL workbench YML file generator plugin to generate the YML files . Hope it helps.

Categories