i'm using cakephp version 2.3.6, ive been trying to upload cake to a hostgator server through CPanel but been having problems configuring the index.php file in the webroot but not sure the correct configuration for my version of cake on Cpanel my cpanel username is fredenda I tried to configure this in cpanel but keeps on giving this error message
" Parse error: syntax error, unexpected ';' in /home/fredenda/public_html/index.php on line 41"
however this error isnt in the file, Please can someone help me out.
Please check the file below... bless.
<?php
/**
* Index
*
* The Front Controller for handling every request
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* #copyright Copyright (c) Cake Software Foundation, Inc.
(http://cakefoundation.org)
* #link http://cakephp.org CakePHP(tm) Project
* #package app.webroot
* #since CakePHP(tm) v 0.2.9
* #license http://www.opensource.org/licenses/mit-license.php MIT License
*/
/**
* Use the DS to separate the directories in other defines
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* When using custom settings be sure to use the DS and do not add a trailing DS.
*/
/**
* The full path to the directory which holds "app", WITHOUT a trailing DS.
*
*/
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.(fredenda);
}
/**
* The actual directory name for the "app".
*
*/
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
}
/**
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
*
* Un-comment this line to specify a fixed path to CakePHP.
* This should point at the directory containing `Cake`.
*
* For ease of development CakePHP uses PHP's include_path. If you
* cannot modify your include_path set this value.
*
* Leaving this constant undefined will result in it being defined in Cake/bootstrap.php
*
* The following line differs from its sibling
* /lib/Cake/Console/Templates/skel/webroot/index.php
*/
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib')
/**
* Editing below this line should NOT be necessary.
* Change at your own risk.
*
*/
if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
define('WWW_ROOT', dirname(__FILE__) . DS);
}
// for built-in server
if (php_sapi_name() == 'cli-server') {
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['REQUEST_URI'])) {
return false;
}
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
}
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (function_exists('ini_set')) {
ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
}
if (!include ('Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
} else {
if (!include (CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'bootstrap.php')) {
$failed = true;
}
}
if (!empty($failed)) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(
new CakeRequest(),
new CakeResponse()
);
Open your eyes. ;) The parser is not lying to you. There is a missing ) but I don't think fredenda is a constant so...
define('ROOT', DS.'home'.DS.(fredenda);
This line should be:
define('ROOT', DS . 'home' . DS. 'fredenda');
I would recommend you to get an editor or IDE with proper php syntax highlighting and syntax check to see these kind of syntax issues immediately.
And follow coding standards, there should be a space between the DS and strings like in all the other places. Also a good read this book "Clean Code".
Related
I'm building my coding habits using C coding standards to improve consistency. I've heard about Doxygen and it's used widely for generating documentation for software projects. I don't know a lot about Doxygen and don't know how to use it, but I found that I can use it to auto-generate comments for files and functions. I know it's all about personal preference, but from an expert perspective does it affect generating documentation if I used something for file header like:
/* =================================================================================================================
FILE DESCRIPTION
------------------------------------------------------------------------------------------------------------------
File : dio.c
Category : drivers - dio
Date : 25 Jan. 2023
Author : Nabil Yasser
Git Account :
Description : Includes DIO driver functions Implementation for ATmega32
==================================================================================================================== */
instead of that includes commands like #author and #date which Doxygen generates:
/**
* #file dio.c
* #author Nabil Yasser
* #brief
* #version 0.1
* #date 31/01/2023
*
* #copyright Copyright (c) 2023
*
*/
and for functios that's what I'm currently using:
/* =================================================================================================================
* Syntax : uint8 dio_setPin(DioPortId_et portId, DioChannelId_et channelId, DioChannelDirection_et direction)
* Description : Sets DIO pins direction as output or input
* Sync/Async : Synchronous
* Reentrancy : Non Reentrant
* Arguments : portId : Port name in which the pin you want to set direction for (GPIOA, GPIOB, GPIOC, GPIOD).
* : channelId : Name of channel/pin you want to set direction for (PIN0 ~ PIN7)
* : direction : Channel/pin direction (INPUT, OUTPUT)
* Output : E_OK (0) : If no problems
* : E_NOK (1) : If there is any problem
==================================================================================================================== */
versus what generated by Doxygen:
/**
* #brief function desciption text
*
* #param portId description about parameter
* #param channelId description about parameter
* #param direction description about parameter
* #return uint8 description about return value
*/
Can any of these affect my ability to use Doxygen or even generally affect readability for other developers in any possible way? or I'm just okay since they're just comments?
I am trying document my code using Doxygen. I want the resulting HTML to organize the tree view acording to a SW architecture for simple and fast understanding of the project. I have a project organized like this:
│ project_description.md
├───application
│ │ application.md
│ ├───app1
│ │ app1.c
│ │ app1.h
│ │ app1.md
│ └───app2
│ app2.c
│ app2.h
│ app2.md
└───ecu_abstraction
│ ecu_abstraction.md
├───component1
│ custom_timer.c
│ custom_timer.h
│ custom_timer.md
└───component2
custom_component2.c
custom_component2.h
custom_component2.md
The issue I am having is that the tree view auto-generated by doxygen is flat. All elements have the same level.
Current result is:
My objective is to have something like this:
I have made some attempts with grouping and sections but all of them seems to merge the documentation files. Any idea if this can be implemented with Doxygen?
I know I can achieve a similar result by disabling the autogenerated tree view and using #ref but creating a manual table of contex is not very flexible nor future proof.
Attempts with addtogroup functionality:
Adding the line #addtogroup application in the markdown files concatenates them in the module "application".
Adding to a group specific functions or the module declaration to a group adds those functions to the same generic module description.
This means that if I add all my applications to the application layer all of those are concatenated and one single page is created.
Sample markdown file:
#addtogroup application
# App1
bla bla
Sample C file addition to a group
/**
* #addtogroup application
* #{
* #file app2.c
*
* #brief Custom simpe timer implementation that allows for simple tick, reste...
* #}
*/
It's a little bit late answer, the OP may have solved the matter who knows. Anyway, the implementation according to the OP's requirement should be like the following steps. Assume that we have the source files as *.h and *.c pair:
app1
app2
custom_component
custom_timer
First we would implement a application doc file:
app_doc.dox
/**
* \mainpage X Application Project
* \author Author Name <author_email#example.com>
*
* Description for X Application Project.
*/
/**
* \defgroup app Application Layer
* #{
* Description for the Application group.
* #}
*/
/**
* \defgroup ecu ECU Abstraction Layer
* #{
* Description for the ECU Abstraction group.
* #}
*/
Next we would document all indiviual files. But we create new groups using the defgroup command within the related header files only. Right after creating the groups, we make them subgroups using the ingroup command. This will nest the groups and create a hierarchic documentation within the tree view as a result. Note that we also add the *.c file to their related groups. However this may not be necessary unless you have more documentations that belong the same group in the *.c files.
app1.h
/**
* \defgroup app1 App1
* \ingroup app
*
* \author Author Name (Optional)
* \date YYYY.MM.DD (Optional)
*
* #{
* Description for this specific app1 module (Optional).
*/
#ifndef APP1_H
#define APP1_H
/**
* app1Func documentation.
*/
void app1Func(void);
#endif /* APP1_H */
/// #}
app1.c
/**
* \ingroup app1
*
*/
void app1Func(void) {
}
app2.h
/**
* \defgroup app2 App2
* \ingroup app
*
* \author Author Name (Optional)
* \date YYYY.MM.DD (Optional)
*
* #{
* Description for this specific app2 module (Optional).
*/
#ifndef APP2_H
#define APP2_H
/**
* app2Func documentation.
*/
void app2Func(void);
#endif /* APP2_H */
/// #}
app2.c
/**
* \ingroup app2
*
*/
void app2Func(void) {
}
custom_timer.h
/**
* \defgroup custom_timer Custom Timer SWC
* \ingroup ecu
*
* \author Author Name (Optional)
* \date YYYY.MM.DD (Optional)
*
* #{
* Description for this specific custom_timer module (Optional).
*/
#ifndef CUSTOM_TIMER_H
#define CUSTOM_TIMER_H
/**
* customTimerFunc documentation.
*/
void customTimerFunc(void);
#endif /* CUSTOM_TIMER_H */
/// #}
custom_timer.c
/**
* \ingroup custom_timer
*
*/
void customTimerFunc(void) {
}
custom_component.h
/**
* \defgroup custom_component Custom Component SWC
* \ingroup ecu
*
* \author Author Name (Optional)
* \date YYYY.MM.DD (Optional)
*
* #{
* Description for this specific custom_component module (Optional)
*/
#ifndef CUSTOM_COMPONENT_H
#define CUSTOM_COMPONENT_H
/**
* customComponentFunc documentation.
*/
void customComponentFunc(void);
#endif /* CUSTOM_COMPONENT_H */
/// #}
custom_component.c
/**
* \ingroup custom_component
*
*/
void customComponentFunc(void) {
}
The Doxygen version I used to generate documentation is 1.9.6. I have generated the documentation using Doxywizard in Linux platform. Finally an image that shows the result.
Unfortunately I cannot add the specific doxygen config file since it is large and there is a body character limit in answers. But no worries I uploaded it in a cloud storage so that you can download and view.
Edit
Thanks to #albert for the reminder so I also leave the doxygen configuration as condensed view form in case of the original Doxyfile is not available from the cloud drive.
# Doxyfile 1.9.6
PROJECT_NAME = "X Application Project"
PROJECT_NUMBER = 1.0.0
PROJECT_BRIEF = "This is the X Project's synopsis"
OUTPUT_DIRECTORY = .
OPTIMIZE_OUTPUT_FOR_C = YES
SHOW_HEADERFILE = NO
SHOW_INCLUDE_FILES = NO
SHOW_USED_FILES = NO
SHOW_FILES = NO
INPUT = . \
../Xproject
GENERATE_TREEVIEW = YES
FULL_SIDEBAR = YES
GENERATE_LATEX = NO
Im trying to upload a file in a SwaggerUI, but it keeps saying no file found, can't figure out why exactly, maybe you guys can help me:
/**
* #SWG\Put(
* path="/api/v1/profile/{id}/profilepicture",
* tags={"Profile"},
* operationId="updateProfilePicture",
* summary="updates the ProfilePicture",
* description="updates the ProfilePicture",
* consumes={"multipart/form-data"},
* produces={"application/json"},
* #SWG\Parameter(
* name="profilePicture",
* in="formData",
* description="Change the profilepicture",
* required=true,
* type="file",
* #SWG\Schema(ref="#definitions/Error"),
* ),
* #SWG\Response(
* response=200,
* description="Succeed!",
* ),
* #SWG\Response(
* response=405,
* description="Validation exception",
* ),
* )
* #param Request $request
* #return BinaryFileResponse
*/
public function updateProfilePicture(Request $request)
{
$profileId = $request->get('id');
/** #var UploadedFile $file */
$file = $request->files->get('profilePicture');
if($file == null)
{
throw new BadRequestHttpException('No file found!');
}
return (new BinaryFileResponse($file));
}
tried changing the name of profilePicture and clearing the cache, still have the same problem.
I'm having this problem while seeding my PGSQL Database:
Illuminate\Database\QueryException : SQLSTATE[22021]: Character not in repertoire: 7 ERROR: secuencia de bytes no válida para codificación «UTF8»: 0xe3 0x83 0xe2 (SQL: insert into "races" ("name", "public_name", "members", "updated_at", "created_at") values (harp��a, HarpÃa, 23, 2018-04-21 20:30:20, 2018-04-21 20:30:20) returning "id")
at C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 PDOException::("SQLSTATE[22021]: Character not in repertoire: 7 ERROR: secuencia de bytes no válida para codificación «UTF8»: 0xe3 0x83 0xe2")
C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:330
2 PDOStatement::execute()
C:\Sandbox\rpgforum\vendor\laravel\framework\src\Illuminate\Database\Connection.php:330
Please use the argument -v to see more details.
And this is my Seeder's code:
<?php
use Illuminate\Database\Seeder;
use App\Models\Race;
class RaceTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* #return void
*/
public function run()
{
$races = [
'Humano',
'Orco',
'Elfo',
'Harpía',
'Enano',
];
for ($i = 0; $i < count($races); $i++) {
$race_i = utf8_encode($races[$i]);
$race = Race::create([
'name' => strtolower($race_i),
'public_name' => $race_i,
'members' => mt_rand(10,30),
]);
} // for
}
}
My database configuration:
pgsql database
My config.database file config:
config.database file
Is there any solution for this problem? I can find the way to get rid of this problem...
EDIT:
I just noticed something weird. I got two records in my database:
database records
And both of them have symbols that gave me problem with the seeder. Maybe the problem is within the seeders logic? I'm doing the exact same thing I do the whole time with my Laravel/Postgresql projects so i can't find the reason why i can't seed words with accent mark but i can use a simple form to store that kind of information. Any ideas ?
I have folder with files for different build environment like production,stage, and test.
example:
src/config.prod.js
src/config.stage.js
src/config.test.js
what I want is to copy config file based on environment I got, for getting environment name from command i using following code:
var nopt = require('nopt')
, knownOpts = {
"env" : [String, null]
}
, shortHands = {
"test" : ["--env", "test"]
, "dev" : ["--dev", "dev"]
, "stage" : ["--env", "stage"]
, "prod" : ["--env", "prod"]
};
var flags = nopt(knownOpts, shortHands, process.argv, 2);
and when I hit command
gulp build --env dev
I am getting the environment name, now what I want is to copy config file to dist folder(build) based on environment. I have this task for copy file but it copy all files as I don't know how to filter it out.
gulp.task('copyConfig', function(){
gulp.src(['src/*.js'])
.pipe(gulp.dest('dist/'))
})
I am new to gulp, if some one has any suggestion. please help.
new configs directory where you mv your 3, existing configs (prod, stage, test) ... mkdir configs
Then , 2 related changes to gulp to incorporate build.ENV and a copy.config task that knows about your 3 diff config files...
var settings = {
/*
* Environment development | production
* match './configs' files of same name
*/
environment : process.env.NODE_ENV || 'development',
/*
* Where is our config folder?
*/
configFolder : 'configs',
/*
* Where is our code?
*/
srcFolder : 'app/scripts',
/*
* Where are we building to?
*/
buildFolder : 'dist',
};
/**
* Config Task
*
* Get the configuration file (dev or prod), rename it
* and move it to be built.
*/
gulp.task('config', function() {
return gulp.src(settings.configFolder + '/' + settings.environment + '.js')
.pipe(rename('config.js'))
.pipe(gulp.dest(settings.srcFolder));
});