Run a laravel application - php

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.

Related

Laravel 8 – create route alias for image folder inside public directory

I’m in the middle of the process of replicating a framework that I developed in node / react to laravel. Right now, I’m adjusting the main architecture and currently working on a blade master page.
My original idea (Laravel 8 – use blade asset to display image, but loading from resources subfolder) didn’t work, so I’m trying a new approach to set up how I want my asset files to be served.
The assets in question is basically images for layout purposes. I organized the directory like so:
public/app_files_layout
Inside it, I have a bunch of image files that I want to access. The thing is that I don’t want to access like http://localhost:8000/app_files_layout/image-name.jpg. My intention is to access like: http://localhost:8000/images/image-name.jpg, but I want to maintain the directory names I created intact, so it can have a high fidelity architectural organization similar to my framework that I built in other languages.
I figured that I would set up a simple routing logic for it in Laravel web.php file. I followed the suggestion from this stackoverflow question:
https://stackoverflow.com/a/38736973/2510785
However, when I try to access via browser through the following address http://localhost:8000/files-layout-test/image-name.jpg, returned me an error like so:
The requested resource /files-layout-test/image-name.jpg was not found on this server.
I stripped the code just to try to find out what could be wrong, and this is what I did to debug it:
Route::get('/files-layout-test/{filename}', function($filename){
echo 'debug';
});
The strange behavior is that, when I try to access without the file extension (ex: http://localhost:8000/files-layout-test/image-name), it goes through, but I need the file extension to be there.
Any ideas on how I could get this done?
Note: I’m new to Laravel, so the answer may be simple.
Basically for simple stuff like creating a symlink for public/images and public/app_files_layout you can use the built-in storage:link command.
In your config/filesystems.php file, you can define the symlinks you want to create
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => public_path('app_files_layout'),
],
Then you can run php artisan storage:link and it will create all the symlinks defined the links array in config/filesystems.php. No need to create any custom Artisan command. You can read more at Laravel Docs
With the above symlink created you can use the asset() helper to generate the urls for assets which are actually in public/app_files_layout using asset('images/filename.ext').
You can also access public/app_files_layout/image-name.ext at http://localhost:8000/images/image-name.ext once the symlink is created.
However if you want to add some other logic or say you want to get user input for creating symlinks then you can define your own custom Artisan command using the storage:link command as starting point

I try to add wordpress blog to existing PHP Laravel project

I have a PHP Laravel project hosted on Heroku with a Postgresql database and I want to add a Wordpress blog to /blog.
I added in the public folder a blog folder and then copied the last version of WordPress there.
After that, I followed, starting with step 6, this tutorial: http://www.merocode.com/hosting-wordpress-blog-on-heroku-with-support-of-postgres/. I also replaced the wp_config variables with the ones provided on Heroku.
After deploying it to Heroku and trying to test my_site.herokuapp.com/blog I get:
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /app/public/blog/wp-content/pg4wp/core.php(32) : eval()'d code on line 1612
Connecting to your PostgreSQL database without a password is considered insecure.
If you want to do it anyway, please set "PG4WP_INSECURE" to true in your "db.php" file.
Can anyone help me with this problem? Do you know another good tutorial with all the steps that can help me host a WordPress blog to an existing PHP Laravel project?
Thank you!
Laravel and Wordpress should be separated!
This error is not related to Laravel. Check your Wordpress files and versions or your webserver config.
Correct solution:
Create a new config in your webserver and define new routes for /blog and separate your project folders.

Migrate file in 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

Installing Aauth doesn't work

i'm new on CodeIgniter and i try to install Aauth. But the installation Guide is not so clear.
I put the application/libraries/Aauth.php in libraries, application/config/aauth.php in config and application/controller/example.php in controller.
Next I import the sql file in phpmyadmin (with aauth for DB name). After that i put the halpers in helper folder even if it's not mentionned. Same for languages.
And then
You must set up database connections from
application/config/database.php
I tried database' => 'aauth'.
You can also make some changes on application/config/aauth.php"
I don't know what to do? I have never used a framework before.
I created a controller and put $this->load->library("Aauth"); in __construct, and did the tutorial.
Problems are:
Fatal error: Call to undefined method Aauth::deny()
If i dont use the deny function, there is no error but when i look in the DB I only have legolas and no frodo or gandalf. But all perms and groups are there.
If I give "immortality to hobbits", it still say that hobbits do not "immortality".
I work with Xampp and Codeigniter 3 on Windows 10.
You do not have to change anything in your database config file. Just make sure db_profile in the Aauth config matches the name of the database active_group.
As for the Aauth config, for CI3, change use_cookies to false.
To load the library, change the name to lowercase, $this->load->library("aauth");

Error on Zend controller creation

I'm attempting to build a test project with the Zend framework and using MAMP to run it on my local host.
The project creation works fine; I navigate to my htdocs directory and use zf create project my_zend to create the scaffold.
My error comes when I try to create a controller "students" by using the following command zf create controller students, however, once this command runs it outputs the following error:
Context by name servicesDirectory does not exist in the registry.
Where does this error come from?
I had the same problem, here is how I fixed it, check for the line:
<servicesDirectory enabled="false"/>
In the .zfproject.xml file and remove it.
You might get this error if you have another version of zend some where in the path. If you have one try deleting it and using the latest or the version you wish to. This worked for me in xamp on windows 7 hope it works for you

Categories