• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP env函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中env函数的典型用法代码示例。如果您正苦于以下问题:PHP env函数的具体用法?PHP env怎么用?PHP env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了env函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: postUserSettings

 public function postUserSettings()
 {
     $error = false;
     if (Request::has('user_id')) {
         $user_id = (int) Auth::user()->user_id;
         $input_id = (int) Request::input('user_id');
         if (Request::input('roles') === null) {
             $roles = [];
         } else {
             $roles = Request::input('roles');
         }
         if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
             $roles[] = env('ROLE_ADMIN');
             $error = true;
         }
         $editUser = User::find(Request::input('user_id'));
         $editUser->roles()->sync($roles);
         $editUser->save();
         $this->streamingUser->update();
     }
     if ($error) {
         return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
     }
     return redirect()->back();
 }
开发者ID:quentin-sommer,项目名称:WebTv,代码行数:25,代码来源:AdminController.php


示例2: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('password');
         $table->boolean('active');
         $table->boolean('banned');
         $table->string('register_ip');
         $table->string('country_code');
         $table->string('locale');
         $table->string('activation_key');
         $table->boolean('su');
         $table->rememberToken();
         $table->timestamps();
     });
     $user = \Laralum::newUser();
     $user->name = env('USER_NAME', 'admin');
     $user->email = env('USER_EMAIL', '[email protected]');
     $user->password = bcrypt(env('USER_PASSWORD', 'admin123'));
     $user->active = true;
     $user->banned = false;
     $user->register_ip = "";
     $user->country_code = env('USER_COUNTRY_CODE', 'ES');
     $user->locale = env('USER_LOCALE', 'en');
     $user->activation_key = str_random(25);
     $user->su = true;
     $user->save();
 }
开发者ID:ConsoleTVs,项目名称:Laralum,代码行数:35,代码来源:2014_10_12_000000_create_users_table.php


示例3: __construct

 function __construct(Router $router, Response $response)
 {
     $this->router = $router;
     $this->response = $response;
     $this->post = new Lazy($_POST);
     $this->get = new Lazy($_GET);
     $this->server = new Lazy($_SERVER);
     $this->files = new Lazy($_FILES);
     $parsedUrl = parse_url($_SERVER['REQUEST_URI'] ?? '/');
     $url = $parsedUrl['path'];
     $envPrefix = env()->getUrlPrefix();
     // replace environment prefix
     if (strpos($url, $envPrefix) === 0) {
         $url = substr($url, strlen($envPrefix));
     }
     // default url if empty
     if (!$url) {
         $url = '/';
     } else {
         if (strlen($url) > 1 && substr($url, -1) == "/") {
             // add / to beginning
             $url = substr($url, 0, -1);
         }
     }
     $this->url = $url;
 }
开发者ID:pckg,项目名称:framework,代码行数:26,代码来源:Request.php


示例4: register

 public function register()
 {
     $this->app->configure("mail");
     $this->app->register(MailServiceProvider::class);
     $this->app->singleton(MailClerk::class, function () {
         return new MailClerk(app("mailer"));
     });
     $this->app->extend("swift.transport", function (TransportManager $manager) {
         $manager->extend("slack", function () {
             $token = env("SLACKMAIL_APIKEY");
             $channel = env("SLACKMAIL_CHANNEL");
             return new SlackTransport($token, $channel);
         });
         $manager->extend("sendgrid", function () {
             if (class_exists(\SendGrid::class)) {
                 $sendgrid = new \SendGrid(env("SENDGRID_APIKEY"));
                 return new SendGridTransport($sendgrid);
             } else {
                 throw new \Exception("SendGrid class not found. plz install via `composer install sendgrid/sendgrid`");
             }
         });
         $manager->extend("array", function () {
             return new ArrayTransport();
         });
         return $manager;
     });
 }
开发者ID:chatbox-inc,项目名称:mailclerk,代码行数:27,代码来源:MailClerkServiceProvider.php


示例5: run

 public function run()
 {
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     }
     if (env('DB_DRIVER') == 'mysql') {
         DB::table(config('access.roles_table'))->truncate();
     } else {
         //For PostgreSQL or anything else
         DB::statement("TRUNCATE TABLE " . config('access.roles_table') . " CASCADE");
     }
     //Create admin role, id of 1
     $role_model = config('access.role');
     $admin = new $role_model();
     $admin->name = 'Administrator';
     $admin->all = true;
     $admin->sort = 1;
     $admin->created_at = Carbon::now();
     $admin->updated_at = Carbon::now();
     $admin->save();
     //id = 2
     $role_model = config('access.role');
     $user = new $role_model();
     $user->name = 'User';
     $user->sort = 2;
     $user->created_at = Carbon::now();
     $user->updated_at = Carbon::now();
     $user->save();
     if (env('DB_DRIVER') == 'mysql') {
         DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     }
 }
开发者ID:Interlista,项目名称:HackADev,代码行数:32,代码来源:RoleTableSeeder.php


示例6: isColumnNullable

 public static function isColumnNullable($column_name)
 {
     $instance = new static();
     // create an instance of the model to be able to get the table name
     $answer = DB::select(DB::raw("SELECT IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='" . $instance->getTable() . "' AND COLUMN_NAME='" . $column_name . "' AND table_schema='" . env('DB_DATABASE') . "'"))[0];
     return $answer->IS_NULLABLE == 'YES' ? true : false;
 }
开发者ID:Ghitu,项目名称:crud,代码行数:7,代码来源:CrudTrait.php


示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $images = $request->input('images');
     $gallery_name = 'gallery_' . time();
     $directory = 'uploads/' . $gallery_name . '/';
     mkdir($directory, 0755);
     $gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
     foreach ($images as $image) {
         $url = $image['url'];
         $img = Image::make($url);
         $img->resize(800, null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         preg_match('/\\.[^\\.]+$/i', $url, $ext);
         $filename = $directory . time() . $ext[0];
         $stream = $img->stream();
         $s3 = Storage::disk('s3');
         $s3->put($filename, $stream->__toString(), 'public');
         $client = $s3->getDriver()->getAdapter()->getClient();
         $public_url = $client->getObjectUrl(env('S3_BUCKET'), $filename);
         $gallery->images()->create(['url' => $public_url]);
     }
     $response = ['message' => 'Images successfully uploaded', 'redirect' => url('gallery', $gallery_name)];
     return response()->json($response);
 }
开发者ID:realnerdo,项目名称:photoshow,代码行数:32,代码来源:GalleriesController.php


示例8: createApplication

 /**
  * Creates the application.
  *
  * @return \Illuminate\Foundation\Application
  */
 public function createApplication()
 {
     $app = (require __DIR__ . '/../bootstrap/app.php');
     $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
     $this->baseUrl = env('APP_URL');
     return $app;
 }
开发者ID:adiachenko,项目名称:rabbits,代码行数:12,代码来源:TestCase.php


示例9: testConstructor

 /**
  * test applying settings in the constructor
  *
  * @return void
  */
 public function testConstructor()
 {
     $object = new BasicAuthenticate($this->Collection, array('userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password')));
     $this->assertEquals('AuthUser', $object->settings['userModel']);
     $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']);
     $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']);
 }
开发者ID:angel-mendoza,项目名称:proyecto-pasantia,代码行数:12,代码来源:BasicAuthenticateTest.php


示例10: env

 function env($key)
 {
     if ($key === 'HTTPS') {
         if (isset($_SERVER['HTTPS'])) {
             return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off';
         }
         return strpos(env('SCRIPT_URI'), 'https://') === 0;
     }
     if ($key === 'SCRIPT_NAME') {
         if (env('CGI_MODE') && isset($_ENV['SCRIPT_URL'])) {
             $key = 'SCRIPT_URL';
         }
     }
     $val = null;
     if (isset($_SERVER[$key])) {
         $val = $_SERVER[$key];
     } elseif (isset($_ENV[$key])) {
         $val = $_ENV[$key];
     } elseif (getenv($key) !== false) {
         $val = getenv($key);
     }
     if ($key === 'REMOTE_ADDR' && $val === env('SERVER_ADDR')) {
         $addr = env('HTTP_PC_REMOTE_ADDR');
         if ($addr !== null) {
             $val = $addr;
         }
     }
     if ($val !== null) {
         return $val;
     }
     return null;
 }
开发者ID:Djtec,项目名称:HumbFramework,代码行数:32,代码来源:Basics.php


示例11: setDomains

 private static function setDomains($domain = false, $subdomain = false)
 {
     if ($domain !== false && $subdomain !== false) {
         // set domain and subdomain manually
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     } else {
         $domain = env('DOMAIN');
         $subdomain = '';
         //set subdomain - parse the actual url
         if (isset($_SERVER['HTTP_HOST'])) {
             $arr = explode('.', $_SERVER['HTTP_HOST']);
             if (count($arr) == 2) {
                 // if the array is only a length of 2, that means it is the domain name plus extension,
                 // eg. nowarena.com, so no subdomain
                 $subdomain = '';
             } else {
                 $subdomain = strtolower($arr[0]);
             }
         }
         // set values based on what was determined in config/app.php
         self::$domain = $domain;
         self::$subdomain = $subdomain;
     }
 }
开发者ID:nowarena,项目名称:homestead,代码行数:25,代码来源:Site.php


示例12: fire

 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $tasks = Task::where('date', '>=', Carbon::parse(date('d-m-Y')))->where('date', '<=', Carbon::parse(date('d-m-Y'))->addDay(7))->orderBy('date', 'asc')->get();
     \Mail::send('emails.remainder', ['tasks' => $tasks], function ($m) {
         $m->to(env('REMAINDER_EMAIL'), env('REMAINDER_NAME'))->subject('[SUN TASK] Your Task Reminder.');
     });
 }
开发者ID:princesust,项目名称:SUN-TASK,代码行数:12,代码来源:Remainder.php


示例13: sendNotificationEmail

 public function sendNotificationEmail(Group $group, User $user)
 {
     if ($user->verified == 1) {
         // Establish timestamp for notifications from membership data (when was an email sent for the last time?)
         $membership = \App\Membership::where('user_id', '=', $user->id)->where('group_id', "=", $group->id)->firstOrFail();
         $last_notification = $membership->notified_at;
         // find unread discussions since timestamp
         $discussions = QueryHelper::getUnreadDiscussionsSince($user->id, $group->id, $membership->notified_at);
         // find new files since timestamp
         $files = \App\File::where('updated_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->get();
         // find new members since timestamp
         $users = QueryHelper::getNewMembersSince($user->id, $group->id, $membership->notified_at);
         // find future actions until next 2 weeks, this is curently hardcoded... TODO use the mail sending interval to determine stop date
         $actions = \App\Action::where('start', '>', Carbon::now())->where('stop', '<', Carbon::now()->addWeek()->addWeek())->where('group_id', "=", $group->id)->orderBy('start')->get();
         // we only trigger mail sending if a new action has been **created** since last notfication email.
         // BUT we will send actions for the next two weeks in all cases, IF a mail must be sent
         $actions_count = \App\Action::where('created_at', '>', $membership->notified_at)->where('group_id', "=", $group->id)->count();
         // in all cases update timestamp
         $membership->notified_at = Carbon::now();
         $membership->save();
         // if we have anything, build the message and send
         // removed that : or count($users) > 0
         // because we don't want to be notified just because there is a new member
         if (count($discussions) > 0 or count($files) > 0 or $actions_count > 0) {
             Mail::send('emails.notification', ['user' => $user, 'group' => $group, 'membership' => $membership, 'discussions' => $discussions, 'files' => $files, 'users' => $users, 'actions' => $actions, 'last_notification' => $last_notification], function ($message) use($user, $group) {
                 $message->from(env('MAIL_NOREPLY', '[email protected]'), env('APP_NAME', 'Laravel'))->to($user->email)->subject('[' . env('APP_NAME') . '] ' . trans('messages.news_from_group_email_subject') . ' "' . $group->name . '"');
             });
             return true;
         }
         return false;
     }
 }
开发者ID:philippejadin,项目名称:Mobilizator,代码行数:32,代码来源:AppMailer.php


示例14: addDummyDataToTasks

 private function addDummyDataToTasks()
 {
     $i = 0;
     $this->tasks = array_map(function ($task) use(&$i) {
         return array_merge($task, ['title' => 'a task', 'priority' => 'low', 'isClosed' => false, 'projectPHIDs' => ['x'], 'ownerPHID' => null, 'id' => ++$i, 'auxiliary' => [env('MANIPHEST_STORY_POINTS_FIELD') => $task['points']]]);
     }, $this->tasks);
 }
开发者ID:r8j3,项目名称:phragile,代码行数:7,代码来源:TaskListTest.php


示例15: createGuestPost

 public function createGuestPost(Requests\Bins\CreateGuestBin $request)
 {
     $recaptcha = new ReCaptcha(env('RECAPTCHA_SECRET'));
     $response = $recaptcha->verify($request->input('grc-response'), $_SERVER['REMOTE_ADDR']);
     if (!$response->isSuccess()) {
         session()->flash('error', 'You must prove you are human by completing the catpcha!');
         return redirect()->route('bins.create');
     }
     $description = $request->has('description') && trim($request->input('description')) != '' ? $request->input('description') : null;
     $bin = Bin::create(['title' => $request->input('title'), 'description' => $description, 'visibility' => $request->input('visibility')]);
     $bin->versions()->sync($request->input('versions'));
     $files = [];
     foreach ($request->input('name') as $key => $value) {
         $files[$key]['name'] = $value;
     }
     foreach ($request->input('language') as $key => $value) {
         $files[$key]['language'] = $value;
     }
     foreach ($request->input('code') as $key => $value) {
         $files[$key]['code'] = $value;
     }
     foreach ($files as $item) {
         $type = Type::where('css_class', $item['language'])->first();
         $bin->snippets()->create(['type_id' => $type->id, 'name' => $item['name'], 'code' => $item['code']]);
     }
     session()->flash('success', 'Bin created successfully!');
     return redirect()->route('bin.code', $bin->getRouteKey());
 }
开发者ID:everdaniel,项目名称:LaraBin,代码行数:28,代码来源:BinController.php


示例16: emailAccident

 /**
  * Email Accident
  */
 public function emailAccident()
 {
     $site = Site::findOrFail($this->site_id);
     $email_list = env('EMAIL_ME');
     if (\App::environment('dev', 'prod')) {
         $email_list = "[email protected]; [email protected]; [email protected]; [email protected]; " . $email_list;
         foreach ($site->supervisors as $super) {
             if (preg_match(VALID_EMAIL_PATTERN, $super->email)) {
                 $email_list .= '; ' . $super->email;
             }
         }
     }
     $email_list = trim($email_list);
     $email_list = explode(';', $email_list);
     $email_list = array_map('trim', $email_list);
     // trim white spaces
     $email_user = \App::environment('dev', 'prod') ? Auth::user()->email : '';
     $data = ['id' => $this->id, 'site' => $site->name . ' (' . $site->code . ')', 'address' => $site->address . ', ' . $site->SuburbStatePostcode, 'date' => $this->date->format('d/m/Y g:i a'), 'worker' => $this->name . ' (age: ' . $this->age . ')', 'occupation' => $this->occupation, 'location' => $this->location, 'nature' => $this->nature, 'referred' => $this->referred, 'damage' => $this->damage, 'description' => $this->info, 'user_fullname' => User::find($this->created_by)->fullname, 'user_company_name' => User::find($this->created_by)->company->name, 'submit_date' => $this->created_at->format('d/m/Y g:i a'), 'site_owner' => $site->client->clientOfCompany->name];
     Mail::send('emails.siteAccident', $data, function ($m) use($email_list, $email_user) {
         $m->from('[email protected]');
         $m->to($email_list);
         if (preg_match(VALID_EMAIL_PATTERN, $email_user)) {
             $m->cc($email_user);
         }
         $m->subject('WHS Accident Notification');
     });
 }
开发者ID:unclefudge,项目名称:whs,代码行数:30,代码来源:SiteAccident.php


示例17: paginateByParams

 /**
  * @param \Symfony\Component\HttpFoundation\ParameterBag $params
  * @param int                                            $page
  * @param int                                            $perPage
  *
  * @return array
  */
 public function paginateByParams(ParameterBag $params, $page = null, $perPage = null)
 {
     $query = $this->_query();
     if ($this->queryDelegate) {
         $query = call_user_func_array($this->queryDelegate, [$query, $params]);
     } else {
         foreach ($params as $name => $value) {
             if ($this->hasColumn($name)) {
                 $query->where($name, '=', $value);
             }
         }
     }
     $method = 'defaultOrderByString';
     if (in_array($method, get_class_methods($this->modelClass))) {
         $orderBy = call_user_func([$this->modelClass, $method]);
         if ($orderBy) {
             $query->orderByRaw($orderBy);
         }
     }
     !$perPage && ($perPage = intval(env('RESTFUL_PER_PAGE', 40)));
     !$page && ($page = 1);
     /** @var \Illuminate\Pagination\LengthAwarePaginator $paginator */
     $paginator = $query->paginate($perPage, ['*'], 'page', $page);
     $array = $paginator->toArray();
     return ['total' => $array['total'], 'per_page' => $array['per_page'], 'next_page_ur' => $this->_pageUrl($array['next_page_url'], $params), 'prev_page_url' => $this->_pageUrl($array['prev_page_url'], $params), 'current_page' => $array['current_page'], 'last_page' => max($array['last_page'], 1), 'list' => $array['data']];
 }
开发者ID:vampirekiss,项目名称:lumen-restful-starter-kit,代码行数:33,代码来源:ModelRepository.php


示例18: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Exception               $e
  *
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     $debug = env('APP_DEBUG', false);
     $message = $e->getMessage();
     if (!$message) {
         $message = 'An error occurred';
     }
     $debugData = ['exception' => get_class($e), 'message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => explode("\n", $e->getTraceAsString())];
     $responseData = ['message' => $message];
     if ($e instanceof HttpExceptionInterface) {
         if (method_exists($e, 'getResponse')) {
             if ($e instanceof TransformableInterface) {
                 $responseData = $e->transform(app(ValidationExceptionTransformer::class));
             } else {
                 $responseData = $e->getResponse();
             }
         }
     }
     if ($debug) {
         $responseData['debug'] = $debugData;
     }
     $response = parent::render($request, $e);
     $response = new JsonResponse($responseData, $response->getStatusCode(), $response->headers->all(), JSON_PRETTY_PRINT);
     $response->exception = $e;
     app('Asm89\\Stack\\CorsService')->addActualRequestHeaders($response, $request);
     return $response;
 }
开发者ID:spira,项目名称:api-core,代码行数:35,代码来源:Handler.php


示例19: sync

 /**
  * Sync the media. Oh sync the media.
  *
  * @param string|null $path
  * @param array       $tags        The tags to sync.
  *                                 Only taken into account for existing records.
  *                                 New records will have all tags synced in regardless.
  * @param bool        $force       Whether to force syncing even unchanged files
  * @param SyncMedia   $syncCommand The SyncMedia command object, to log to console if executed by artisan.
  */
 public function sync($path = null, $tags = [], $force = false, SyncMedia $syncCommand = null)
 {
     if (!app()->runningInConsole()) {
         set_time_limit(env('APP_MAX_SCAN_TIME', 600));
     }
     $path = $path ?: Setting::get('media_path');
     $this->setTags($tags);
     $results = ['good' => [], 'bad' => [], 'ugly' => []];
     $getID3 = new getID3();
     foreach ($this->gatherFiles($path) as $file) {
         $file = new File($file, $getID3);
         $song = $file->sync($this->tags, $force);
         if ($song === true) {
             $results['ugly'][] = $file;
         } elseif ($song === false) {
             $results['bad'][] = $file;
         } else {
             $results['good'][] = $file;
         }
         if ($syncCommand) {
             $syncCommand->logToConsole($file->getPath(), $song);
         }
     }
     // Delete non-existing songs.
     $hashes = array_map(function ($f) {
         return self::getHash($f->getPath());
     }, array_merge($results['ugly'], $results['good']));
     Song::whereNotIn('id', $hashes)->delete();
     // Trigger LibraryChanged, so that TidyLibrary handler is fired to, erm, tidy our library.
     event(new LibraryChanged());
 }
开发者ID:carriercomm,项目名称:koel,代码行数:41,代码来源:Media.php


示例20: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (false === env('APP_INSTALLED', false)) {
         return redirect(route('installer.index'));
     }
     return $next($request);
 }
开发者ID:cvepdb-cms,项目名称:module-installer,代码行数:15,代码来源:CMSInstalled.php



注:本文中的env函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP environment函数代码示例发布时间:2022-05-15
下一篇:
PHP enurl_redirect函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap